Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2020-08-04 20:37:12 +10:00
commit dbeac5eb49
2 changed files with 10 additions and 4 deletions

View File

@ -19,8 +19,10 @@
package org.eclipse.jetty.websocket.javax.common; package org.eclipse.jetty.websocket.javax.common;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
import javax.websocket.CloseReason; import javax.websocket.CloseReason;
import javax.websocket.Session; import javax.websocket.Session;
@ -30,12 +32,12 @@ import org.eclipse.jetty.util.component.Graceful;
public class SessionTracker extends AbstractLifeCycle implements JavaxWebSocketSessionListener, Graceful public class SessionTracker extends AbstractLifeCycle implements JavaxWebSocketSessionListener, Graceful
{ {
private final CopyOnWriteArraySet<JavaxWebSocketSession> sessions = new CopyOnWriteArraySet<>(); private final Set<JavaxWebSocketSession> sessions = Collections.newSetFromMap(new ConcurrentHashMap<>());
private boolean isShutdown = false; private boolean isShutdown = false;
public Set<Session> getSessions() public Set<Session> getSessions()
{ {
return Collections.unmodifiableSet(sessions); return Set.copyOf(sessions);
} }
@Override @Override

View File

@ -19,8 +19,12 @@
package org.eclipse.jetty.websocket.common; package org.eclipse.jetty.websocket.common;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.component.AbstractLifeCycle;
@ -31,12 +35,12 @@ import org.eclipse.jetty.websocket.api.WebSocketSessionListener;
public class SessionTracker extends AbstractLifeCycle implements WebSocketSessionListener, Graceful public class SessionTracker extends AbstractLifeCycle implements WebSocketSessionListener, Graceful
{ {
private final List<Session> sessions = new CopyOnWriteArrayList<>(); private final Set<Session> sessions = Collections.newSetFromMap(new ConcurrentHashMap<>());
private boolean isShutdown = false; private boolean isShutdown = false;
public Collection<Session> getSessions() public Collection<Session> getSessions()
{ {
return sessions; return Set.copyOf(sessions);
} }
@Override @Override