|
23 | 23 | import java.util.Collection;
|
24 | 24 | import java.util.Collections;
|
25 | 25 | import java.util.EventListener;
|
26 |
| -import java.util.HashMap; |
27 | 26 | import java.util.Iterator;
|
28 | 27 | import java.util.List;
|
29 | 28 | import java.util.Map;
|
|
35 | 34 | import java.util.concurrent.TimeoutException;
|
36 | 35 | import java.util.concurrent.atomic.AtomicInteger;
|
37 | 36 | import java.util.concurrent.atomic.AtomicLong;
|
38 |
| -import java.util.concurrent.atomic.AtomicReference; |
39 | 37 | import java.util.function.BiConsumer;
|
40 | 38 | import java.util.function.Consumer;
|
41 | 39 | import java.util.function.Predicate;
|
@@ -94,11 +92,11 @@ public abstract class HTTP2Session extends AbstractLifeCycle implements Session,
|
94 | 92 | private static final int MAX_TOTAL_LOCAL_STREAMS = Integer.MAX_VALUE / 2;
|
95 | 93 |
|
96 | 94 | private final Map<Integer, HTTP2Stream> streams = new ConcurrentHashMap<>();
|
| 95 | + private final Map<Integer, Integer> localSettings = new ConcurrentHashMap<>(); |
| 96 | + private final Map<Integer, Integer> remoteSettings = new ConcurrentHashMap<>(); |
97 | 97 | private final Set<Integer> priorityStreams = ConcurrentHashMap.newKeySet();
|
98 | 98 | private final List<FrameListener> frameListeners = new CopyOnWriteArrayList<>();
|
99 | 99 | private final List<LifeCycleListener> lifeCycleListeners = new CopyOnWriteArrayList<>();
|
100 |
| - private final AtomicReference<Map<Integer, Integer>> localSettingsSnapshot = new AtomicReference<>(Map.of()); |
101 |
| - private final AtomicReference<Map<Integer, Integer>> remoteSettingsSnapshot = new AtomicReference<>(Map.of()); |
102 | 100 | private final AtomicLong streamsOpened = new AtomicLong();
|
103 | 101 | private final AtomicLong streamsClosed = new AtomicLong();
|
104 | 102 | private final StreamsState streamsState = new StreamsState();
|
@@ -304,26 +302,6 @@ public long getBytesWritten()
|
304 | 302 | return bytesWritten.get();
|
305 | 303 | }
|
306 | 304 |
|
307 |
| - /** |
308 |
| - * Returns a snapshot of the last SETTINGS that this endpoint sent |
309 |
| - * <p>The map keys are SETTINGS ids as defined in {@link SettingsFrame}. |
310 |
| - * @return local (sent) SETTINGS |
311 |
| - */ |
312 |
| - public Map<Integer, Integer> getCurrentLocalSettings() |
313 |
| - { |
314 |
| - return localSettingsSnapshot.get(); |
315 |
| - } |
316 |
| - |
317 |
| - /** |
318 |
| - * Returns a snapshot of the last SETTINGS that the peer sent |
319 |
| - * <p>The map keys are SETTINGS ids as defined in {@link SettingsFrame}. |
320 |
| - * @return remote (received) SETTINGS |
321 |
| - */ |
322 |
| - public Map<Integer, Integer> getCurrentRemoteSettings() |
323 |
| - { |
324 |
| - return remoteSettingsSnapshot.get(); |
325 |
| - } |
326 |
| - |
327 | 305 | @Override
|
328 | 306 | public void onData(DataFrame frame)
|
329 | 307 | {
|
@@ -470,15 +448,7 @@ public void onSettings(SettingsFrame frame, boolean reply)
|
470 | 448 | return;
|
471 | 449 |
|
472 | 450 | Map<Integer, Integer> settings = frame.getSettings();
|
473 |
| - remoteSettingsSnapshot.updateAndGet(origin -> |
474 |
| - { |
475 |
| - if (settings.isEmpty()) |
476 |
| - return origin; |
477 |
| - Map<Integer, Integer> updated = new HashMap<>(origin); |
478 |
| - updated.putAll(settings); |
479 |
| - return Map.copyOf(updated); |
480 |
| - }); |
481 |
| - |
| 451 | + remoteSettings.putAll(settings); |
482 | 452 | configure(settings, false);
|
483 | 453 | notifySettings(this, frame);
|
484 | 454 |
|
@@ -846,17 +816,8 @@ public void succeeded(Stream pushed)
|
846 | 816 | public void settings(SettingsFrame frame, Callback callback)
|
847 | 817 | {
|
848 | 818 | if (!frame.isReply())
|
849 |
| - { |
850 |
| - Map<Integer, Integer> settings = frame.getSettings(); |
851 |
| - localSettingsSnapshot.updateAndGet(origin -> |
852 |
| - { |
853 |
| - if (settings.isEmpty()) |
854 |
| - return origin; |
855 |
| - Map<Integer, Integer> updated = new HashMap<>(origin); |
856 |
| - updated.putAll(settings); |
857 |
| - return Map.copyOf(updated); |
858 |
| - }); |
859 |
| - } |
| 819 | + localSettings.putAll(frame.getSettings()); |
| 820 | + |
860 | 821 | control(null, callback, frame);
|
861 | 822 | }
|
862 | 823 |
|
@@ -1488,9 +1449,10 @@ protected static boolean isClientStream(int streamId)
|
1488 | 1449 | @Override
|
1489 | 1450 | public void dump(Appendable out, String indent) throws IOException
|
1490 | 1451 | {
|
1491 |
| - DumpableMap localSettings = new DumpableMap("local settings", getCurrentLocalSettings()); |
1492 |
| - DumpableMap remoteSettings = new DumpableMap("remote settings", getCurrentRemoteSettings()); |
1493 |
| - Dumpable.dumpObjects(out, indent, this, flowControl, flusher, new DumpableCollection("streams", streams.values()), localSettings, remoteSettings); |
| 1452 | + DumpableCollection streams = new DumpableCollection("streams", this.streams.values()); |
| 1453 | + DumpableMap localSettings = new DumpableMap("local settings", this.localSettings); |
| 1454 | + DumpableMap remoteSettings = new DumpableMap("remote settings", this.remoteSettings); |
| 1455 | + Dumpable.dumpObjects(out, indent, this, flowControl, flusher, streams, localSettings, remoteSettings); |
1494 | 1456 | }
|
1495 | 1457 |
|
1496 | 1458 | @Override
|
|
0 commit comments