Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit e44b34e

Browse files
authored
Backward Compatible - Http3SettingsFrame abstraction (#15835) (#353)
* [x] Provide a cleaner, more maintainable implementation of `Http3SettingsFrame`. * [x] Replace the previous untyped `LongObjectHashMap`-based approach with a typed `Http3Settings` abstraction. * [x] Improve API clarity and future extensibility for HTTP/3 settings handling (similar to Http2Settings) --- * [x] Introduced `Http3Settings` class to encapsulate and manage HTTP/3 settings. * [x] Deprecated legacy untyped accessors (`get()`, `put()`) in favor of typed methods such as `qpackMaxTableCapacity()` and `enableConnectProtocol()`. * [x] Updated `DefaultHttp3SettingsFrame` to use the new `Http3Settings` internally. * [x] Added detailed Javadoc to guide migration to the new typed API. * [x] Added comprehensive test coverage for `Http3Settings` and its integration with `Http3SettingsFrame`. --- * [x] **Backward-compatible** – existing code using `get()`/`put()` still works (marked deprecated). * [x] **Forward-compatible** – encourages use of typed accessors. * [x] **No behavioral change** – internal structure and API clarity improved only. --- Port of netty/netty#15835
1 parent b598f4f commit e44b34e

6 files changed

Lines changed: 884 additions & 17 deletions

File tree

src/main/java/io/netty/incubator/codec/http3/DefaultHttp3SettingsFrame.java

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,64 @@
1717

1818
import io.netty.util.collection.LongObjectHashMap;
1919
import io.netty.util.collection.LongObjectMap;
20+
import io.netty.util.internal.ObjectUtil;
2021
import io.netty.util.internal.StringUtil;
2122

23+
import javax.annotation.Nullable;
2224
import java.util.Iterator;
2325
import java.util.Map;
2426

2527
public final class DefaultHttp3SettingsFrame implements Http3SettingsFrame {
2628

27-
private final LongObjectMap<Long> settings = new LongObjectHashMap<>(4);
29+
private final Http3Settings settings;
2830

31+
public DefaultHttp3SettingsFrame(Http3Settings settings) {
32+
this.settings = ObjectUtil.checkNotNull(settings, "settings");
33+
}
34+
35+
public DefaultHttp3SettingsFrame() {
36+
this.settings = new Http3Settings();
37+
}
38+
39+
@Override
40+
public Http3Settings settings() {
41+
return settings;
42+
}
43+
44+
/**
45+
* Get a setting by its key.
46+
*
47+
* @param key the HTTP/3 setting key
48+
* @return the value, or {@code null} if not set
49+
* @deprecated use {@link #settings()} and manipulate the {@link Http3Settings} directly
50+
*/
2951
@Override
52+
@Deprecated
53+
@Nullable
3054
public Long get(long key) {
55+
// Legacy behavior: direct map access.
3156
return settings.get(key);
3257
}
3358

59+
/**
60+
* Set a setting value by key.
61+
*
62+
* @param key the HTTP/3 setting key
63+
* @param value the value to set
64+
* @return the previous value, or {@code null} if none
65+
* @throws IllegalArgumentException if the key is reserved for HTTP/2
66+
* @deprecated use {@link #settings()} and manipulate the {@link Http3Settings} directly
67+
*/
3468
@Override
69+
@Deprecated
70+
@Nullable
3571
public Long put(long key, Long value) {
36-
if (Http3CodecUtils.isReservedHttp2Setting(key)) {
37-
throw new IllegalArgumentException("Setting is reserved for HTTP/2: " + key);
38-
}
3972
return settings.put(key, value);
4073
}
4174

4275
@Override
4376
public Iterator<Map.Entry<Long, Long>> iterator() {
44-
return settings.entrySet().iterator();
77+
return settings.iterator();
4578
}
4679

4780
@Override

0 commit comments

Comments
 (0)