|
19 | 19 | import java.io.IOException;
|
20 | 20 | import java.util.ArrayList;
|
21 | 21 | import java.util.Arrays;
|
| 22 | +import java.util.HashSet; |
22 | 23 | import java.util.List;
|
23 | 24 | import java.util.Map;
|
| 25 | +import java.util.Set; |
24 | 26 | import java.util.TreeMap;
|
25 | 27 | import java.util.concurrent.ConcurrentHashMap;
|
26 | 28 | import java.util.concurrent.atomic.AtomicInteger;
|
@@ -86,7 +88,7 @@ public class SubProtocolWebSocketHandler implements WebSocketHandler,
|
86 | 88 | private final Map<String, SubProtocolHandler> protocolHandlerLookup =
|
87 | 89 | new TreeMap<String, SubProtocolHandler>(String.CASE_INSENSITIVE_ORDER);
|
88 | 90 |
|
89 |
| - private final List<SubProtocolHandler> protocolHandlers = new ArrayList<SubProtocolHandler>(); |
| 91 | + private final Set<SubProtocolHandler> protocolHandlers = new HashSet<SubProtocolHandler>(); |
90 | 92 |
|
91 | 93 | private SubProtocolHandler defaultProtocolHandler;
|
92 | 94 |
|
@@ -129,7 +131,7 @@ public void setProtocolHandlers(List<SubProtocolHandler> protocolHandlers) {
|
129 | 131 | }
|
130 | 132 |
|
131 | 133 | public List<SubProtocolHandler> getProtocolHandlers() {
|
132 |
| - return new ArrayList<SubProtocolHandler>(this.protocolHandlerLookup.values()); |
| 134 | + return new ArrayList<SubProtocolHandler>(this.protocolHandlers); |
133 | 135 | }
|
134 | 136 |
|
135 | 137 |
|
@@ -288,7 +290,7 @@ protected final SubProtocolHandler findProtocolHandler(WebSocketSession session)
|
288 | 290 | handler = this.defaultProtocolHandler;
|
289 | 291 | }
|
290 | 292 | else if (this.protocolHandlers.size() == 1) {
|
291 |
| - handler = this.protocolHandlers.get(0); |
| 293 | + handler = this.protocolHandlers.iterator().next(); |
292 | 294 | }
|
293 | 295 | else {
|
294 | 296 | throw new IllegalStateException("Multiple protocol handlers configured and " +
|
|
0 commit comments