From b4bd5980aaf685503f953faa07ba3fe68ab81326 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 30 Jan 2019 10:00:56 +1100 Subject: [PATCH 1/5] Issue #3298 - Refactor of upgrade request class names Signed-off-by: Lachlan Roberts --- ...> DelegatedJavaxClientUpgradeRequest.java} | 11 +-- ... DelegatedJavaxClientUpgradeResponse.java} | 12 +-- ...pl.java => JavaxClientUpgradeRequest.java} | 18 ++-- .../client/JavaxWebSocketClientContainer.java | 4 +- .../javax/common/JavaxWebSocketContainer.java | 19 +++-- .../JavaxWebSocketFrameHandlerFactory.java | 56 ++++++------ ...bstractJavaxWebSocketFrameHandlerTest.java | 2 +- ...vaxWebSocketServerFrameHandlerFactory.java | 27 +++--- ... DelegatedJavaxServletUpgradeRequest.java} | 10 +-- .../websocket/javax/tests/NetworkFuzzer.java | 4 +- .../client/SessionAddMessageHandlerTest.java | 2 +- .../javax/tests/server/ConfiguratorTest.java | 85 ++++++++++--------- .../websocket/client/WebSocketClient.java | 4 +- ...> DelegatedJettyClientUpgradeRequest.java} | 23 ++--- ... DelegatedJettyClientUpgradeResponse.java} | 14 +-- ...pl.java => JettyClientUpgradeRequest.java} | 25 +++--- .../JettyServerFrameHandlerFactory.java | 4 +- ... DelegatedJettyServletUpgradeRequest.java} | 12 +-- .../jetty/websocket/core/FrameHandler.java | 6 +- ...Request.java => ClientUpgradeRequest.java} | 10 +-- .../core/client/WebSocketCoreClient.java | 4 +- .../core/chat/ChatWebSocketClient.java | 16 ++-- .../client/WebSocketClientServerTest.java | 2 +- 23 files changed, 190 insertions(+), 180 deletions(-) rename jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/{DelegatedClientUpgradeRequest.java => DelegatedJavaxClientUpgradeRequest.java} (84%) rename jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/{DelegatedClientUpgradeResponse.java => DelegatedJavaxClientUpgradeResponse.java} (93%) rename jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/{ClientUpgradeRequestImpl.java => JavaxClientUpgradeRequest.java} (82%) rename jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/{UpgradeRequestAdapter.java => DelegatedJavaxServletUpgradeRequest.java} (89%) rename jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/{DelegatedClientUpgradeRequest.java => DelegatedJettyClientUpgradeRequest.java} (95%) rename jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/{DelegatedClientUpgradeResponse.java => DelegatedJettyClientUpgradeResponse.java} (95%) rename jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/{ClientUpgradeRequestImpl.java => JettyClientUpgradeRequest.java} (86%) rename jetty-websocket/jetty-websocket-server/src/main/java/org/eclipse/jetty/websocket/server/internal/{UpgradeRequestAdapter.java => DelegatedJettyServletUpgradeRequest.java} (97%) rename jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/{UpgradeRequest.java => ClientUpgradeRequest.java} (97%) diff --git a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedClientUpgradeRequest.java b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedJavaxClientUpgradeRequest.java similarity index 84% rename from jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedClientUpgradeRequest.java rename to jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedJavaxClientUpgradeRequest.java index 8b883c86ace..d09d7e0f793 100644 --- a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedClientUpgradeRequest.java +++ b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedJavaxClientUpgradeRequest.java @@ -18,20 +18,21 @@ package org.eclipse.jetty.websocket.javax.client; -import org.eclipse.jetty.websocket.javax.common.UpgradeRequest; - import java.net.URI; import java.security.Principal; +import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; +import org.eclipse.jetty.websocket.javax.common.UpgradeRequest; + /** * Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpRequest} * in the {@link UpgradeRequest} interface. */ -public class DelegatedClientUpgradeRequest implements UpgradeRequest +public class DelegatedJavaxClientUpgradeRequest implements UpgradeRequest { - private final org.eclipse.jetty.websocket.core.client.UpgradeRequest delegate; + private final ClientUpgradeRequest delegate; - public DelegatedClientUpgradeRequest(org.eclipse.jetty.websocket.core.client.UpgradeRequest delegate) + public DelegatedJavaxClientUpgradeRequest(ClientUpgradeRequest delegate) { this.delegate = delegate; } diff --git a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedClientUpgradeResponse.java b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedJavaxClientUpgradeResponse.java similarity index 93% rename from jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedClientUpgradeResponse.java rename to jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedJavaxClientUpgradeResponse.java index f2646dea56c..2709aa88746 100644 --- a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedClientUpgradeResponse.java +++ b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/DelegatedJavaxClientUpgradeResponse.java @@ -18,24 +18,24 @@ package org.eclipse.jetty.websocket.javax.client; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.javax.common.UpgradeResponse; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - /** * Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link HttpResponse} * in the {@link UpgradeResponse} interface. */ -public class DelegatedClientUpgradeResponse implements UpgradeResponse +public class DelegatedJavaxClientUpgradeResponse implements UpgradeResponse { private HttpResponse delegate; - public DelegatedClientUpgradeResponse(HttpResponse response) + public DelegatedJavaxClientUpgradeResponse(HttpResponse response) { this.delegate = response; } diff --git a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/ClientUpgradeRequestImpl.java b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxClientUpgradeRequest.java similarity index 82% rename from jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/ClientUpgradeRequestImpl.java rename to jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxClientUpgradeRequest.java index e11ef886f69..ad338145666 100644 --- a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/ClientUpgradeRequestImpl.java +++ b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxClientUpgradeRequest.java @@ -18,24 +18,26 @@ package org.eclipse.jetty.websocket.javax.client; +import java.net.URI; +import java.util.concurrent.CompletableFuture; + +import javax.websocket.Session; + import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandler; import org.eclipse.jetty.websocket.javax.common.UpgradeRequest; import org.eclipse.jetty.websocket.javax.common.UpgradeResponse; -import javax.websocket.Session; -import java.net.URI; -import java.util.concurrent.CompletableFuture; - -public class ClientUpgradeRequestImpl extends org.eclipse.jetty.websocket.core.client.UpgradeRequest +public class JavaxClientUpgradeRequest extends ClientUpgradeRequest { private final JavaxWebSocketClientContainer containerContext; private final Object websocketPojo; private final CompletableFuture futureJavaxSession; - public ClientUpgradeRequestImpl(JavaxWebSocketClientContainer clientContainer, WebSocketCoreClient coreClient, URI requestURI, Object websocketPojo) + public JavaxClientUpgradeRequest(JavaxWebSocketClientContainer clientContainer, WebSocketCoreClient coreClient, URI requestURI, Object websocketPojo) { super(coreClient, requestURI); this.containerContext = clientContainer; @@ -53,8 +55,8 @@ public class ClientUpgradeRequestImpl extends org.eclipse.jetty.websocket.core.c @Override public FrameHandler getFrameHandler(WebSocketCoreClient coreClient, HttpResponse response) { - UpgradeRequest upgradeRequest = new DelegatedClientUpgradeRequest(this); - UpgradeResponse upgradeResponse = new DelegatedClientUpgradeResponse(response); + UpgradeRequest upgradeRequest = new DelegatedJavaxClientUpgradeRequest(this); + UpgradeResponse upgradeResponse = new DelegatedJavaxClientUpgradeResponse(response); JavaxWebSocketFrameHandler frameHandler = containerContext.newFrameHandler(websocketPojo, upgradeRequest, upgradeResponse, futureJavaxSession); diff --git a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxWebSocketClientContainer.java b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxWebSocketClientContainer.java index e43a2fec36a..9d0b128e01e 100644 --- a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxWebSocketClientContainer.java +++ b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxWebSocketClientContainer.java @@ -125,7 +125,7 @@ public class JavaxWebSocketClientContainer extends JavaxWebSocketContainer imple * @param upgradeRequest the upgrade request information * @return the future for the session, available on success of connect */ - private CompletableFuture connect(ClientUpgradeRequestImpl upgradeRequest) + private CompletableFuture connect(JavaxClientUpgradeRequest upgradeRequest) { CompletableFuture fut = upgradeRequest.getFutureSession(); try @@ -145,7 +145,7 @@ public class JavaxWebSocketClientContainer extends JavaxWebSocketContainer imple Objects.requireNonNull(configuredEndpoint, "WebSocket configured endpoint cannot be null"); Objects.requireNonNull(destURI, "Destination URI cannot be null"); - ClientUpgradeRequestImpl upgradeRequest = new ClientUpgradeRequestImpl(this, getWebSocketCoreClient(), destURI, configuredEndpoint); + JavaxClientUpgradeRequest upgradeRequest = new JavaxClientUpgradeRequest(this, getWebSocketCoreClient(), destURI, configuredEndpoint); EndpointConfig config = configuredEndpoint.getConfig(); if (config != null && config instanceof ClientEndpointConfig) diff --git a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketContainer.java b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketContainer.java index ffd283a8cf4..5f91aa9d13c 100644 --- a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketContainer.java +++ b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketContainer.java @@ -18,19 +18,20 @@ package org.eclipse.jetty.websocket.javax.common; -import org.eclipse.jetty.io.ByteBufferPool; -import org.eclipse.jetty.util.DecoratedObjectFactory; -import org.eclipse.jetty.util.component.ContainerLifeCycle; -import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; - -import javax.websocket.Extension; -import javax.websocket.Session; -import javax.websocket.WebSocketContainer; import java.util.HashSet; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; +import javax.websocket.Extension; +import javax.websocket.Session; +import javax.websocket.WebSocketContainer; + +import org.eclipse.jetty.io.ByteBufferPool; +import org.eclipse.jetty.util.DecoratedObjectFactory; +import org.eclipse.jetty.util.component.ContainerLifeCycle; +import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; + public abstract class JavaxWebSocketContainer extends ContainerLifeCycle implements javax.websocket.WebSocketContainer { private long defaultAsyncSendTimeout = -1; @@ -105,7 +106,7 @@ public abstract class JavaxWebSocketContainer extends ContainerLifeCycle impleme public JavaxWebSocketFrameHandler newFrameHandler(Object websocketPojo, UpgradeRequest upgradeRequest, UpgradeResponse upgradeResponse, CompletableFuture futureSession) { - return getFrameHandlerFactory().newJavaxFrameHandler(websocketPojo, upgradeRequest, upgradeResponse, futureSession); + return getFrameHandlerFactory().newJavaxWebSocketFrameHandler(websocketPojo, upgradeRequest, upgradeResponse, futureSession); } @Override diff --git a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerFactory.java b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerFactory.java index 6692a5d6a06..778b3a3d695 100644 --- a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerFactory.java +++ b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerFactory.java @@ -18,6 +18,32 @@ package org.eclipse.jetty.websocket.javax.common; +import java.io.InputStream; +import java.io.Reader; +import java.lang.annotation.Annotation; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; + +import javax.websocket.CloseReason; +import javax.websocket.Decoder; +import javax.websocket.EndpointConfig; +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.PongMessage; +import javax.websocket.Session; + import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec; import org.eclipse.jetty.websocket.javax.common.decoders.AvailableDecoders; import org.eclipse.jetty.websocket.javax.common.messages.ByteArrayMessageSink; @@ -37,31 +63,6 @@ import org.eclipse.jetty.websocket.javax.common.util.InvalidSignatureException; import org.eclipse.jetty.websocket.javax.common.util.InvokerUtils; import org.eclipse.jetty.websocket.javax.common.util.ReflectUtils; -import javax.websocket.CloseReason; -import javax.websocket.Decoder; -import javax.websocket.EndpointConfig; -import javax.websocket.OnClose; -import javax.websocket.OnError; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.PongMessage; -import javax.websocket.Session; -import java.io.InputStream; -import java.io.Reader; -import java.lang.annotation.Annotation; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; - import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerMetadata.MessageMetadata; @@ -107,8 +108,9 @@ public abstract class JavaxWebSocketFrameHandlerFactory public abstract JavaxWebSocketFrameHandlerMetadata createMetadata(Class endpointClass, EndpointConfig endpointConfig); - public JavaxWebSocketFrameHandler newJavaxFrameHandler(Object endpointInstance, UpgradeRequest upgradeRequest, UpgradeResponse upgradeResponse, - CompletableFuture futureSession) + public JavaxWebSocketFrameHandler newJavaxWebSocketFrameHandler(Object endpointInstance, UpgradeRequest upgradeRequest, + UpgradeResponse upgradeResponse, + CompletableFuture futureSession) { Object endpoint; EndpointConfig config; diff --git a/jetty-websocket/javax-websocket-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractJavaxWebSocketFrameHandlerTest.java b/jetty-websocket/javax-websocket-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractJavaxWebSocketFrameHandlerTest.java index f847260c592..02a7b22bbf1 100644 --- a/jetty-websocket/javax-websocket-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractJavaxWebSocketFrameHandlerTest.java +++ b/jetty-websocket/javax-websocket-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractJavaxWebSocketFrameHandlerTest.java @@ -69,7 +69,7 @@ public abstract class AbstractJavaxWebSocketFrameHandlerTest UpgradeRequest upgradeRequest = new UpgradeRequestAdapter(); UpgradeResponse upgradeResponse = new UpgradeResponseAdapter(); - JavaxWebSocketFrameHandler localEndpoint = factory.newJavaxFrameHandler(endpoint, + JavaxWebSocketFrameHandler localEndpoint = factory.newJavaxWebSocketFrameHandler(endpoint, upgradeRequest, upgradeResponse, new CompletableFuture<>()); return localEndpoint; diff --git a/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/JavaxWebSocketServerFrameHandlerFactory.java b/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/JavaxWebSocketServerFrameHandlerFactory.java index 71e68d39efa..12d7746ae20 100644 --- a/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/JavaxWebSocketServerFrameHandlerFactory.java +++ b/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/JavaxWebSocketServerFrameHandlerFactory.java @@ -18,23 +18,24 @@ package org.eclipse.jetty.websocket.javax.server; -import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec; -import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.javax.server.internal.PathParamIdentifier; -import org.eclipse.jetty.websocket.javax.server.internal.UpgradeRequestAdapter; -import org.eclipse.jetty.websocket.javax.server.internal.UpgradeResponseAdapter; -import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer; -import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory; -import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerMetadata; -import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest; -import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse; -import org.eclipse.jetty.websocket.servlet.FrameHandlerFactory; +import java.util.concurrent.CompletableFuture; import javax.websocket.Endpoint; import javax.websocket.EndpointConfig; import javax.websocket.Session; import javax.websocket.server.ServerEndpoint; -import java.util.concurrent.CompletableFuture; + +import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec; +import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer; +import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory; +import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerMetadata; +import org.eclipse.jetty.websocket.javax.server.internal.DelegatedJavaxServletUpgradeRequest; +import org.eclipse.jetty.websocket.javax.server.internal.PathParamIdentifier; +import org.eclipse.jetty.websocket.javax.server.internal.UpgradeResponseAdapter; +import org.eclipse.jetty.websocket.servlet.FrameHandlerFactory; +import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest; +import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse; public class JavaxWebSocketServerFrameHandlerFactory extends JavaxWebSocketFrameHandlerFactory implements FrameHandlerFactory { @@ -68,6 +69,6 @@ public class JavaxWebSocketServerFrameHandlerFactory extends JavaxWebSocketFrame public FrameHandler newFrameHandler(Object websocketPojo, ServletUpgradeRequest upgradeRequest, ServletUpgradeResponse upgradeResponse) { CompletableFuture completableFuture = new CompletableFuture<>(); - return newJavaxFrameHandler(websocketPojo, new UpgradeRequestAdapter(upgradeRequest), new UpgradeResponseAdapter(upgradeResponse), completableFuture); + return newJavaxWebSocketFrameHandler(websocketPojo, new DelegatedJavaxServletUpgradeRequest(upgradeRequest), new UpgradeResponseAdapter(upgradeResponse), completableFuture); } } diff --git a/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/UpgradeRequestAdapter.java b/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/DelegatedJavaxServletUpgradeRequest.java similarity index 89% rename from jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/UpgradeRequestAdapter.java rename to jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/DelegatedJavaxServletUpgradeRequest.java index ffafa7b4973..c6a2eccde05 100644 --- a/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/UpgradeRequestAdapter.java +++ b/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/DelegatedJavaxServletUpgradeRequest.java @@ -18,17 +18,17 @@ package org.eclipse.jetty.websocket.javax.server.internal; -import org.eclipse.jetty.websocket.javax.common.UpgradeRequest; -import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest; - import java.net.URI; import java.security.Principal; -public class UpgradeRequestAdapter implements UpgradeRequest +import org.eclipse.jetty.websocket.javax.common.UpgradeRequest; +import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest; + +public class DelegatedJavaxServletUpgradeRequest implements UpgradeRequest { private final ServletUpgradeRequest servletRequest; - public UpgradeRequestAdapter(ServletUpgradeRequest servletRequest) + public DelegatedJavaxServletUpgradeRequest(ServletUpgradeRequest servletRequest) { this.servletRequest = servletRequest; } diff --git a/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java b/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java index 5238b8882c2..6d9061280f2 100644 --- a/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java +++ b/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java @@ -38,7 +38,7 @@ import org.eclipse.jetty.websocket.core.Behavior; import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.client.UpgradeRequest; +import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; import org.eclipse.jetty.websocket.core.internal.Generator; @@ -184,7 +184,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab } } - public static class RawUpgradeRequest extends UpgradeRequest + public static class RawUpgradeRequest extends ClientUpgradeRequest { private final CompletableFuture futureCapture; private EndPoint endPoint; diff --git a/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/SessionAddMessageHandlerTest.java b/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/SessionAddMessageHandlerTest.java index c2344a5e270..ebee871ac30 100644 --- a/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/SessionAddMessageHandlerTest.java +++ b/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/SessionAddMessageHandlerTest.java @@ -84,7 +84,7 @@ public class SessionAddMessageHandlerTest JavaxWebSocketFrameHandlerFactory frameHandlerFactory = new JavaxWebSocketClientFrameHandlerFactory(container); CompletableFuture futureSession = new CompletableFuture<>(); - frameHandler = frameHandlerFactory.newJavaxFrameHandler(ei, handshakeRequest, handshakeResponse, futureSession); + frameHandler = frameHandlerFactory.newJavaxWebSocketFrameHandler(ei, handshakeRequest, handshakeResponse, futureSession); frameHandler.onOpen(new FrameHandler.CoreSession.Empty(), Callback.NOOP); // Session diff --git a/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/ConfiguratorTest.java b/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/ConfiguratorTest.java index 3be59d1e298..9dae9ac822d 100644 --- a/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/ConfiguratorTest.java +++ b/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/ConfiguratorTest.java @@ -18,37 +18,6 @@ package org.eclipse.jetty.websocket.javax.tests.server; -import org.eclipse.jetty.http.HttpHeader; -import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.util.log.Log; -import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.core.client.UpgradeRequest; -import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; -import org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketCreator; -import org.eclipse.jetty.websocket.javax.tests.LocalServer; -import org.eclipse.jetty.websocket.javax.tests.Timeouts; -import org.eclipse.jetty.websocket.javax.tests.framehandlers.FrameHandlerTracker; -import org.hamcrest.Matcher; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import javax.websocket.DecodeException; -import javax.websocket.Decoder; -import javax.websocket.EndpointConfig; -import javax.websocket.Extension; -import javax.websocket.HandshakeResponse; -import javax.websocket.OnMessage; -import javax.websocket.Session; -import javax.websocket.server.HandshakeRequest; -import javax.websocket.server.ServerContainer; -import javax.websocket.server.ServerEndpoint; -import javax.websocket.server.ServerEndpointConfig; import java.io.PrintWriter; import java.io.StringWriter; import java.net.InetSocketAddress; @@ -69,6 +38,38 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; +import javax.websocket.DecodeException; +import javax.websocket.Decoder; +import javax.websocket.EndpointConfig; +import javax.websocket.Extension; +import javax.websocket.HandshakeResponse; +import javax.websocket.OnMessage; +import javax.websocket.Session; +import javax.websocket.server.HandshakeRequest; +import javax.websocket.server.ServerContainer; +import javax.websocket.server.ServerEndpoint; +import javax.websocket.server.ServerEndpointConfig; + +import org.eclipse.jetty.http.HttpHeader; +import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.Frame; +import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.OpCode; +import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; +import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; +import org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketCreator; +import org.eclipse.jetty.websocket.javax.tests.LocalServer; +import org.eclipse.jetty.websocket.javax.tests.Timeouts; +import org.eclipse.jetty.websocket.javax.tests.framehandlers.FrameHandlerTracker; +import org.hamcrest.Matcher; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -430,7 +431,7 @@ public class ConfiguratorTest URI wsUri = server.getWsUri().resolve("/capture-request-headers"); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket); + ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.addExtensions("identity"); Future clientConnectFuture = client.connect(upgradeRequest); @@ -454,7 +455,7 @@ public class ConfiguratorTest URI wsUri = server.getWsUri().resolve("/no-extensions"); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket); + ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.addExtensions("identity"); Future clientConnectFuture = client.connect(upgradeRequest); @@ -478,7 +479,7 @@ public class ConfiguratorTest URI wsUri = server.getWsUri().resolve("/capture-request-headers"); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket); + ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.header("X-Dummy", "Bogus"); Future clientConnectFuture = client.connect(upgradeRequest); @@ -503,7 +504,7 @@ public class ConfiguratorTest // First Request FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket); + ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); Future clientConnectFuture = client.connect(upgradeRequest); FrameHandler.CoreSession channel = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); @@ -522,7 +523,7 @@ public class ConfiguratorTest // Second request clientSocket = new FrameHandlerTracker(); - upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket); + upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); clientConnectFuture = client.connect(upgradeRequest); channel = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); @@ -550,7 +551,7 @@ public class ConfiguratorTest URI wsUri = server.getWsUri().resolve("/addr"); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket); + ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); Future clientConnectFuture = client.connect(upgradeRequest); FrameHandler.CoreSession channel = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); @@ -591,7 +592,7 @@ public class ConfiguratorTest ProtocolsConfigurator.seenProtocols.set(null); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket); + ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.setSubProtocols("status"); Future clientConnectFuture = client.connect(upgradeRequest); @@ -610,7 +611,7 @@ public class ConfiguratorTest ProtocolsConfigurator.seenProtocols.set(null); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket); + ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.setSubProtocols("echo", "chat", "status"); Future clientConnectFuture = client.connect(upgradeRequest); @@ -629,7 +630,7 @@ public class ConfiguratorTest ProtocolsConfigurator.seenProtocols.set(null); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket); + ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.header("sec-websocket-protocol", "echo, chat, status"); Future clientConnectFuture = client.connect(upgradeRequest); @@ -648,7 +649,7 @@ public class ConfiguratorTest ProtocolsConfigurator.seenProtocols.set(null); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket); + ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); // header name is not to spec (case wise) upgradeRequest.header("Sec-Websocket-Protocol", "echo, chat, status"); Future clientConnectFuture = client.connect(upgradeRequest); @@ -682,7 +683,7 @@ public class ConfiguratorTest URI wsUri = server.getWsUri().resolve("/timedecoder"); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket); + ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.setSubProtocols("gmt"); Future clientConnectFuture = client.connect(upgradeRequest); diff --git a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java index a9267c39c13..8d6b0f66841 100644 --- a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java +++ b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java @@ -40,7 +40,7 @@ import org.eclipse.jetty.websocket.api.UpgradeRequest; import org.eclipse.jetty.websocket.api.UpgradeResponse; import org.eclipse.jetty.websocket.api.WebSocketBehavior; import org.eclipse.jetty.websocket.api.WebSocketPolicy; -import org.eclipse.jetty.websocket.client.impl.ClientUpgradeRequestImpl; +import org.eclipse.jetty.websocket.client.impl.JettyClientUpgradeRequest; import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandler; import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandlerFactory; import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; @@ -107,7 +107,7 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketPoli */ public CompletableFuture connect(Object websocket, URI toUri, UpgradeRequest request) throws IOException { - ClientUpgradeRequestImpl upgradeRequest = new ClientUpgradeRequestImpl(this, coreClient, request, toUri, websocket); + JettyClientUpgradeRequest upgradeRequest = new JettyClientUpgradeRequest(this, coreClient, request, toUri, websocket); coreClient.connect(upgradeRequest); return upgradeRequest.getFutureSession(); } diff --git a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedClientUpgradeRequest.java b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java similarity index 95% rename from jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedClientUpgradeRequest.java rename to jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java index 5c18b6a9f36..9df6187f8ae 100644 --- a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedClientUpgradeRequest.java +++ b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java @@ -18,14 +18,6 @@ package org.eclipse.jetty.websocket.client.impl; -import org.eclipse.jetty.http.HttpField; -import org.eclipse.jetty.http.HttpHeader; -import org.eclipse.jetty.io.EndPoint; -import org.eclipse.jetty.util.MultiMap; -import org.eclipse.jetty.util.UrlEncoded; -import org.eclipse.jetty.websocket.api.UpgradeRequest; -import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; - import java.net.HttpCookie; import java.net.SocketAddress; import java.net.URI; @@ -35,19 +27,28 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.eclipse.jetty.http.HttpField; +import org.eclipse.jetty.http.HttpHeader; +import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.util.MultiMap; +import org.eclipse.jetty.util.UrlEncoded; +import org.eclipse.jetty.websocket.api.UpgradeRequest; +import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; +import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; + import static java.nio.charset.StandardCharsets.UTF_8; /** * Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpRequest} * in the {@link UpgradeRequest} interface. */ -public class DelegatedClientUpgradeRequest implements UpgradeRequest +public class DelegatedJettyClientUpgradeRequest implements UpgradeRequest { - private final org.eclipse.jetty.websocket.core.client.UpgradeRequest delegate; + private final ClientUpgradeRequest delegate; private SocketAddress localSocketAddress; private SocketAddress remoteSocketAddress; - public DelegatedClientUpgradeRequest(org.eclipse.jetty.websocket.core.client.UpgradeRequest delegate) + public DelegatedJettyClientUpgradeRequest(ClientUpgradeRequest delegate) { this.delegate = delegate; } diff --git a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedClientUpgradeResponse.java b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java similarity index 95% rename from jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedClientUpgradeResponse.java rename to jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java index 6fd75b00d5e..44bc2a3563d 100644 --- a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedClientUpgradeResponse.java +++ b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java @@ -18,11 +18,6 @@ package org.eclipse.jetty.websocket.client.impl; -import org.eclipse.jetty.client.HttpResponse; -import org.eclipse.jetty.http.HttpHeader; -import org.eclipse.jetty.websocket.api.UpgradeResponse; -import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; - import java.io.IOException; import java.util.Collections; import java.util.List; @@ -30,15 +25,20 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.http.HttpHeader; +import org.eclipse.jetty.websocket.api.UpgradeResponse; +import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; + /** * Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpResponse} * in the {@link UpgradeResponse} interface. */ -public class DelegatedClientUpgradeResponse implements UpgradeResponse +public class DelegatedJettyClientUpgradeResponse implements UpgradeResponse { private HttpResponse delegate; - public DelegatedClientUpgradeResponse(HttpResponse response) + public DelegatedJettyClientUpgradeResponse(HttpResponse response) { this.delegate = response; } diff --git a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/ClientUpgradeRequestImpl.java b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/JettyClientUpgradeRequest.java similarity index 86% rename from jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/ClientUpgradeRequestImpl.java rename to jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/JettyClientUpgradeRequest.java index 9e7e98d8834..fcb9ebebf4d 100644 --- a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/ClientUpgradeRequestImpl.java +++ b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/JettyClientUpgradeRequest.java @@ -18,34 +18,35 @@ package org.eclipse.jetty.websocket.client.impl; +import java.net.HttpCookie; +import java.net.URI; +import java.util.List; +import java.util.concurrent.CompletableFuture; + import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.websocket.api.Session; +import org.eclipse.jetty.websocket.api.UpgradeRequest; import org.eclipse.jetty.websocket.api.UpgradeResponse; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandler; import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.client.UpgradeRequest; +import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; -import java.net.HttpCookie; -import java.net.URI; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -public class ClientUpgradeRequestImpl extends UpgradeRequest +public class JettyClientUpgradeRequest extends ClientUpgradeRequest { private final WebSocketClient containerContext; private final Object websocketPojo; private final CompletableFuture onOpenFuture; private final CompletableFuture futureSession; - private final DelegatedClientUpgradeRequest handshakeRequest; + private final DelegatedJettyClientUpgradeRequest handshakeRequest; - public ClientUpgradeRequestImpl(WebSocketClient clientContainer, WebSocketCoreClient coreClient, org.eclipse.jetty.websocket.api.UpgradeRequest request, - URI requestURI, Object websocketPojo) + public JettyClientUpgradeRequest(WebSocketClient clientContainer, WebSocketCoreClient coreClient, UpgradeRequest request, + URI requestURI, Object websocketPojo) { super(coreClient, requestURI); this.containerContext = clientContainer; @@ -89,7 +90,7 @@ public class ClientUpgradeRequestImpl extends UpgradeRequest version(HttpVersion.fromString(request.getHttpVersion())); } - handshakeRequest = new DelegatedClientUpgradeRequest(this); + handshakeRequest = new DelegatedJettyClientUpgradeRequest(this); } @Override @@ -108,7 +109,7 @@ public class ClientUpgradeRequestImpl extends UpgradeRequest @Override public FrameHandler getFrameHandler(WebSocketCoreClient coreClient, HttpResponse response) { - UpgradeResponse upgradeResponse = new DelegatedClientUpgradeResponse(response); + UpgradeResponse upgradeResponse = new DelegatedJettyClientUpgradeResponse(response); JettyWebSocketFrameHandler frameHandler = containerContext.newFrameHandler(websocketPojo, handshakeRequest, upgradeResponse, onOpenFuture); diff --git a/jetty-websocket/jetty-websocket-server/src/main/java/org/eclipse/jetty/websocket/server/JettyServerFrameHandlerFactory.java b/jetty-websocket/jetty-websocket-server/src/main/java/org/eclipse/jetty/websocket/server/JettyServerFrameHandlerFactory.java index 47bbd03d4e6..4c800db2389 100644 --- a/jetty-websocket/jetty-websocket-server/src/main/java/org/eclipse/jetty/websocket/server/JettyServerFrameHandlerFactory.java +++ b/jetty-websocket/jetty-websocket-server/src/main/java/org/eclipse/jetty/websocket/server/JettyServerFrameHandlerFactory.java @@ -29,7 +29,7 @@ import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandlerFactory; import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.server.internal.UpgradeRequestAdapter; +import org.eclipse.jetty.websocket.server.internal.DelegatedJettyServletUpgradeRequest; import org.eclipse.jetty.websocket.server.internal.UpgradeResponseAdapter; import org.eclipse.jetty.websocket.servlet.FrameHandlerFactory; import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest; @@ -67,7 +67,7 @@ public class JettyServerFrameHandlerFactory @Override public FrameHandler newFrameHandler(Object websocketPojo, ServletUpgradeRequest upgradeRequest, ServletUpgradeResponse upgradeResponse) { - return super.newJettyFrameHandler(websocketPojo, new UpgradeRequestAdapter(upgradeRequest), new UpgradeResponseAdapter(upgradeResponse), + return super.newJettyFrameHandler(websocketPojo, new DelegatedJettyServletUpgradeRequest(upgradeRequest), new UpgradeResponseAdapter(upgradeResponse), new CompletableFuture<>()); } diff --git a/jetty-websocket/jetty-websocket-server/src/main/java/org/eclipse/jetty/websocket/server/internal/UpgradeRequestAdapter.java b/jetty-websocket/jetty-websocket-server/src/main/java/org/eclipse/jetty/websocket/server/internal/DelegatedJettyServletUpgradeRequest.java similarity index 97% rename from jetty-websocket/jetty-websocket-server/src/main/java/org/eclipse/jetty/websocket/server/internal/UpgradeRequestAdapter.java rename to jetty-websocket/jetty-websocket-server/src/main/java/org/eclipse/jetty/websocket/server/internal/DelegatedJettyServletUpgradeRequest.java index b7e74c93cf7..b2d17f0873a 100644 --- a/jetty-websocket/jetty-websocket-server/src/main/java/org/eclipse/jetty/websocket/server/internal/UpgradeRequestAdapter.java +++ b/jetty-websocket/jetty-websocket-server/src/main/java/org/eclipse/jetty/websocket/server/internal/DelegatedJettyServletUpgradeRequest.java @@ -18,10 +18,6 @@ package org.eclipse.jetty.websocket.server.internal; -import org.eclipse.jetty.websocket.api.UpgradeRequest; -import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; -import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest; - import java.net.HttpCookie; import java.net.URI; import java.security.Principal; @@ -29,11 +25,15 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -public class UpgradeRequestAdapter implements UpgradeRequest +import org.eclipse.jetty.websocket.api.UpgradeRequest; +import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; +import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest; + +public class DelegatedJettyServletUpgradeRequest implements UpgradeRequest { private final ServletUpgradeRequest servletRequest; - public UpgradeRequestAdapter(ServletUpgradeRequest servletRequest) + public DelegatedJettyServletUpgradeRequest(ServletUpgradeRequest servletRequest) { this.servletRequest = servletRequest; } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/FrameHandler.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/FrameHandler.java index cb54e59fadb..ccb1136ee52 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/FrameHandler.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/FrameHandler.java @@ -27,7 +27,7 @@ import java.util.Map; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.websocket.core.client.UpgradeRequest; +import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.core.server.Negotiation; /** @@ -42,8 +42,8 @@ import org.eclipse.jetty.websocket.core.server.Negotiation; *
  • On the server, the application layer must provide a {@link org.eclipse.jetty.websocket.core.server.WebSocketNegotiator} instance * to negotiate and accept websocket connections, which will return the FrameHandler instance to use from * {@link org.eclipse.jetty.websocket.core.server.WebSocketNegotiator#negotiate(Negotiation)}.
  • - *
  • On the client, the application returns the FrameHandler instance to user from the {@link UpgradeRequest} - * instance that it passes to the {@link org.eclipse.jetty.websocket.core.client.WebSocketCoreClient#connect(UpgradeRequest)} method/
  • + *
  • On the client, the application returns the FrameHandler instance to user from the {@link ClientUpgradeRequest} + * instance that it passes to the {@link org.eclipse.jetty.websocket.core.client.WebSocketCoreClient#connect(ClientUpgradeRequest)} method/
  • * *

    * Once instantiated the FrameHandler follows is used as follows: diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeRequest.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java similarity index 97% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeRequest.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java index 183a6df6b88..ed5141903cf 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeRequest.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java @@ -64,11 +64,11 @@ import org.eclipse.jetty.websocket.core.internal.WebSocketChannel; import org.eclipse.jetty.websocket.core.internal.WebSocketConnection; import org.eclipse.jetty.websocket.core.internal.WebSocketCore; -public abstract class UpgradeRequest extends HttpRequest implements Response.CompleteListener, HttpConnectionUpgrader +public abstract class ClientUpgradeRequest extends HttpRequest implements Response.CompleteListener, HttpConnectionUpgrader { - public static UpgradeRequest from(WebSocketCoreClient webSocketClient, URI requestURI, FrameHandler frameHandler) + public static ClientUpgradeRequest from(WebSocketCoreClient webSocketClient, URI requestURI, FrameHandler frameHandler) { - return new UpgradeRequest(webSocketClient, requestURI) + return new ClientUpgradeRequest(webSocketClient, requestURI) { @Override public FrameHandler getFrameHandler(WebSocketCoreClient coreClient, HttpResponse response) @@ -78,7 +78,7 @@ public abstract class UpgradeRequest extends HttpRequest implements Response.Com }; } - private static final Logger LOG = Log.getLogger(UpgradeRequest.class); + private static final Logger LOG = Log.getLogger(ClientUpgradeRequest.class); protected final CompletableFuture futureCoreSession; private final WebSocketCoreClient wsClient; private List upgradeListeners = new ArrayList<>(); @@ -91,7 +91,7 @@ public abstract class UpgradeRequest extends HttpRequest implements Response.Com */ private List subProtocols = new ArrayList<>(); - public UpgradeRequest(WebSocketCoreClient webSocketClient, URI requestURI) + public ClientUpgradeRequest(WebSocketCoreClient webSocketClient, URI requestURI) { super(webSocketClient.getHttpClient(), new HttpConversation(), requestURI); diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java index 58fae3df9f2..3d247f3414f 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java @@ -83,11 +83,11 @@ public class WebSocketCoreClient extends ContainerLifeCycle implements FrameHand public CompletableFuture connect(FrameHandler frameHandler, URI wsUri) throws IOException { - UpgradeRequest request = UpgradeRequest.from(this, wsUri, frameHandler); + ClientUpgradeRequest request = ClientUpgradeRequest.from(this, wsUri, frameHandler); return connect(request); } - public CompletableFuture connect(UpgradeRequest request) throws IOException + public CompletableFuture connect(ClientUpgradeRequest request) throws IOException { if (!isStarted()) { diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java index ea0344a654f..565a481f4c6 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java @@ -18,13 +18,6 @@ package org.eclipse.jetty.websocket.core.chat; -import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.util.log.Log; -import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.websocket.core.MessageHandler; -import org.eclipse.jetty.websocket.core.client.UpgradeRequest; -import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; - import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URI; @@ -34,6 +27,13 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.MessageHandler; +import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; +import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; + public class ChatWebSocketClient { private static Logger LOG = Log.getLogger(ChatWebSocketClient.class); @@ -51,7 +51,7 @@ public class ChatWebSocketClient URI wsUri = baseWebsocketUri.resolve("/chat"); handler = MessageHandler.from(this::onText, null); - UpgradeRequest request = UpgradeRequest.from(client, wsUri, handler); + ClientUpgradeRequest request = ClientUpgradeRequest.from(client, wsUri, handler); request.setSubProtocols("chat"); client.connect(request).get(5, TimeUnit.SECONDS); handler.sendText("[" + name + ": has joined the room]", Callback.NOOP, false); diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/client/WebSocketClientServerTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/client/WebSocketClientServerTest.java index bf642358376..46fd2210de9 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/client/WebSocketClientServerTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/client/WebSocketClientServerTest.java @@ -179,7 +179,7 @@ public class WebSocketClientServerTest public void start() throws Exception { - UpgradeRequest request = UpgradeRequest.from(client, baseWebSocketUri.resolve("/test"), handler); + ClientUpgradeRequest request = ClientUpgradeRequest.from(client, baseWebSocketUri.resolve("/test"), handler); request.setSubProtocols("test"); this.client.start(); Future response = client.connect(request); From bd4f9b30fc565e0b0ec7f134fbe53517344267ea Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Thu, 31 Jan 2019 11:13:05 +1100 Subject: [PATCH 2/5] Issue #3298 - cleanup of CompletableFutures for WebSocket upgrades Jetty and Javax ClientUpgradeRequests no longer use the combination of the the onOpenFuture and the futureCoreSession and instead use only the CompletableFuture future given to the FrameHandler onOpen Signed-off-by: Lachlan Roberts --- .../javax/client/JavaxClientUpgradeRequest.java | 10 +++++----- .../javax/common/JavaxWebSocketFrameHandler.java | 7 +++---- .../client/impl/JettyClientUpgradeRequest.java | 9 +++------ .../websocket/common/JettyWebSocketFrameHandler.java | 4 ++-- .../websocket/core/client/ClientUpgradeRequest.java | 7 ++++--- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxClientUpgradeRequest.java b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxClientUpgradeRequest.java index ad338145666..b3ee91af5dc 100644 --- a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxClientUpgradeRequest.java +++ b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxClientUpgradeRequest.java @@ -35,21 +35,21 @@ public class JavaxClientUpgradeRequest extends ClientUpgradeRequest { private final JavaxWebSocketClientContainer containerContext; private final Object websocketPojo; - private final CompletableFuture futureJavaxSession; + private final CompletableFuture futureSession; public JavaxClientUpgradeRequest(JavaxWebSocketClientContainer clientContainer, WebSocketCoreClient coreClient, URI requestURI, Object websocketPojo) { super(coreClient, requestURI); this.containerContext = clientContainer; this.websocketPojo = websocketPojo; - this.futureJavaxSession = new CompletableFuture<>(); + this.futureSession = new CompletableFuture<>(); } @Override protected void handleException(Throwable failure) { super.handleException(failure); - futureJavaxSession.completeExceptionally(failure); + futureSession.completeExceptionally(failure); } @Override @@ -58,13 +58,13 @@ public class JavaxClientUpgradeRequest extends ClientUpgradeRequest UpgradeRequest upgradeRequest = new DelegatedJavaxClientUpgradeRequest(this); UpgradeResponse upgradeResponse = new DelegatedJavaxClientUpgradeResponse(response); - JavaxWebSocketFrameHandler frameHandler = containerContext.newFrameHandler(websocketPojo, upgradeRequest, upgradeResponse, futureJavaxSession); + JavaxWebSocketFrameHandler frameHandler = containerContext.newFrameHandler(websocketPojo, upgradeRequest, upgradeResponse, futureSession); return frameHandler; } public CompletableFuture getFutureSession() { - return futureJavaxSession; + return futureSession; } } diff --git a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java index 7cf65580df8..1e11426fe81 100644 --- a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java +++ b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java @@ -29,6 +29,7 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; + import javax.websocket.CloseReason; import javax.websocket.Decoder; import javax.websocket.EndpointConfig; @@ -229,16 +230,14 @@ public class JavaxWebSocketFrameHandler implements FrameHandler openHandle.invoke(); container.addBean(session, true); - futureSession.complete(session); callback.succeeded(); + futureSession.complete(session); } catch (Throwable cause) { Exception wse = new WebSocketException(endpointInstance.getClass().getName() + " OPEN method error: " + cause.getMessage(), cause); - - // TODO This feels like double handling of the exception? Review need for futureSession - futureSession.completeExceptionally(wse); callback.failed(wse); + futureSession.completeExceptionally(wse); } } diff --git a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/JettyClientUpgradeRequest.java b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/JettyClientUpgradeRequest.java index fcb9ebebf4d..de112f4d05a 100644 --- a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/JettyClientUpgradeRequest.java +++ b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/JettyClientUpgradeRequest.java @@ -41,7 +41,6 @@ public class JettyClientUpgradeRequest extends ClientUpgradeRequest { private final WebSocketClient containerContext; private final Object websocketPojo; - private final CompletableFuture onOpenFuture; private final CompletableFuture futureSession; private final DelegatedJettyClientUpgradeRequest handshakeRequest; @@ -51,9 +50,7 @@ public class JettyClientUpgradeRequest extends ClientUpgradeRequest super(coreClient, requestURI); this.containerContext = clientContainer; this.websocketPojo = websocketPojo; - - this.onOpenFuture = new CompletableFuture<>(); - this.futureSession = super.futureCoreSession.thenCombine(onOpenFuture, (channel, session) -> session); + this.futureSession = new CompletableFuture<>(); if (request != null) { @@ -103,7 +100,7 @@ public class JettyClientUpgradeRequest extends ClientUpgradeRequest protected void handleException(Throwable failure) { super.handleException(failure); - onOpenFuture.completeExceptionally(failure); + futureSession.completeExceptionally(failure); } @Override @@ -112,7 +109,7 @@ public class JettyClientUpgradeRequest extends ClientUpgradeRequest UpgradeResponse upgradeResponse = new DelegatedJettyClientUpgradeResponse(response); JettyWebSocketFrameHandler frameHandler = containerContext.newFrameHandler(websocketPojo, - handshakeRequest, upgradeResponse, onOpenFuture); + handshakeRequest, upgradeResponse, futureSession); return frameHandler; } diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java index 91d8a1d2485..4682668e9f0 100644 --- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java +++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java @@ -141,13 +141,13 @@ public class JettyWebSocketFrameHandler implements FrameHandler if (openHandle != null) openHandle.invoke(); - futureSession.complete(session); callback.succeeded(); + futureSession.complete(session); } catch (Throwable cause) { - // TODO should futureSession be failed here? callback.failed(new WebSocketException(endpointInstance.getClass().getName() + " OPEN method error: " + cause.getMessage(), cause)); + futureSession.completeExceptionally(cause); } } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java index ed5141903cf..42b0a485b55 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java @@ -347,11 +347,12 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon try { endp.upgrade(wsConnection); - } - finally - { futureCoreSession.complete(wsChannel); } + catch (Throwable t) + { + futureCoreSession.completeExceptionally(t); + } } /** From 6a98cc0bd28c0922f2abf3f9f73918991908dc2f Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Thu, 31 Jan 2019 22:24:09 +1100 Subject: [PATCH 3/5] Issue #3298 - bug fixes for jetty websockets succeed callback when you do not have a message sink OnWebSocketFrame annotation should take an API frame not a core frame Signed-off-by: Lachlan Roberts --- .../jetty/websocket/common/JettyWebSocketFrameHandler.java | 3 +++ .../websocket/common/JettyWebSocketFrameHandlerFactory.java | 3 +-- .../websocket/common/endpoints/annotated/FrameSocket.java | 2 +- .../org/eclipse/jetty/websocket/tests/JettyWebsocketTest.java | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java index 4682668e9f0..a1a3e224e0f 100644 --- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java +++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java @@ -236,7 +236,10 @@ public class JettyWebSocketFrameHandler implements FrameHandler { // No message sink is active if (activeMessageSink == null) + { + callback.succeeded(); return; + } // Accept the payload into the message sink activeMessageSink.accept(frame, callback); diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java index e1f26a58bd0..a06d5fce560 100644 --- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java +++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java @@ -61,7 +61,6 @@ import org.eclipse.jetty.websocket.common.message.PartialTextMessageSink; import org.eclipse.jetty.websocket.common.message.ReaderMessageSink; import org.eclipse.jetty.websocket.common.message.StringMessageSink; import org.eclipse.jetty.websocket.common.util.ReflectUtils; -import org.eclipse.jetty.websocket.core.Frame; /** * Factory to create {@link JettyWebSocketFrameHandler} instances suitable for @@ -351,7 +350,7 @@ public class JettyWebSocketFrameHandlerFactory extends ContainerLifeCycle { assertSignatureValid(endpointClass, onmethod, OnWebSocketFrame.class); final InvokerUtils.Arg SESSION = new InvokerUtils.Arg(Session.class); - final InvokerUtils.Arg FRAME = new InvokerUtils.Arg(Frame.class).required(); + final InvokerUtils.Arg FRAME = new InvokerUtils.Arg(org.eclipse.jetty.websocket.api.extensions.Frame.class).required(); MethodHandle methodHandle = InvokerUtils.mutatedInvoker(endpointClass, onmethod, SESSION, FRAME); metadata.setFrameHandler(methodHandle, onmethod); } diff --git a/jetty-websocket/jetty-websocket-common/src/test/java/org/eclipse/jetty/websocket/common/endpoints/annotated/FrameSocket.java b/jetty-websocket/jetty-websocket-common/src/test/java/org/eclipse/jetty/websocket/common/endpoints/annotated/FrameSocket.java index 90687dd21c6..3d7e97ed992 100644 --- a/jetty-websocket/jetty-websocket-common/src/test/java/org/eclipse/jetty/websocket/common/endpoints/annotated/FrameSocket.java +++ b/jetty-websocket/jetty-websocket-common/src/test/java/org/eclipse/jetty/websocket/common/endpoints/annotated/FrameSocket.java @@ -20,7 +20,7 @@ package org.eclipse.jetty.websocket.common.endpoints.annotated; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketFrame; import org.eclipse.jetty.websocket.api.annotations.WebSocket; -import org.eclipse.jetty.websocket.core.Frame; +import org.eclipse.jetty.websocket.api.extensions.Frame; @WebSocket public class FrameSocket diff --git a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebsocketTest.java b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebsocketTest.java index 42bbf1b10c1..9f3f69adca7 100644 --- a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebsocketTest.java +++ b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebsocketTest.java @@ -40,7 +40,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; -public class JettyWebsocketTest +public class JettyWebSocketTest { @WebSocket From 77b7e275ccfe80f99ce332062fe42ff0a1530848 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Mon, 4 Feb 2019 14:54:27 +1100 Subject: [PATCH 4/5] Issue #3298 - fix to pom file Signed-off-by: Lachlan Roberts --- jetty-websocket/jetty-websocket-tests/pom.xml | 47 ++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/jetty-websocket/jetty-websocket-tests/pom.xml b/jetty-websocket/jetty-websocket-tests/pom.xml index 04ffd5cb160..bc7556acb69 100644 --- a/jetty-websocket/jetty-websocket-tests/pom.xml +++ b/jetty-websocket/jetty-websocket-tests/pom.xml @@ -8,15 +8,15 @@ 10.0.0-SNAPSHOT - 4.0.0 + 4.0.0 jetty-websocket-tests Jetty :: Websocket :: org.eclipse.jetty.websocket :: Tests - - ${project.groupId}.jetty.tests + + ${project.groupId}.jetty.websocket.tests - + org.eclipse.jetty.websocket jetty-websocket-api @@ -32,6 +32,11 @@ jetty-websocket-server ${project.version} + + org.eclipse.jetty.tests + jetty-http-tools + ${project.version} + org.eclipse.jetty.toolchain jetty-test-helper @@ -39,40 +44,28 @@ - + - org.apache.maven.plugins - maven-enforcer-plugin + org.apache.felix + maven-bundle-plugin + true - ban-java-servlet-api - enforce + manifest - - - - javax.servlet - servletapi - org.eclipse.jetty.orbit:javax.servlet - org.mortbay.jetty:servlet-api - jetty:servlet-api - - - + + jetty.websocket Integration Tests + + org.eclipse.jetty.websocket.jetty.tests.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}" + + - - org.apache.maven.plugins - maven-deploy-plugin - - true - - From bfcb890ab230556b148523843279d5f970bd447e Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Mon, 4 Feb 2019 15:05:15 +1100 Subject: [PATCH 5/5] Issue #3298 - rename typo in JettyWebSocketTest name Signed-off-by: Lachlan Roberts --- .../tests/{JettyWebsocketTest.java => JettyWebSocketTest.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/{JettyWebsocketTest.java => JettyWebSocketTest.java} (100%) diff --git a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebsocketTest.java b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketTest.java similarity index 100% rename from jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebsocketTest.java rename to jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketTest.java