From 0d571ef2c24a7388a0031e5c972abd6be5667534 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Mon, 30 Dec 2019 13:25:30 +1100 Subject: [PATCH 01/12] Issue #4450 - websocket Extensions no longer rely upon WSCoreSession Signed-off-by: Lachlan Roberts --- .../jetty/websocket/core/AbstractExtension.java | 12 ++++++------ .../eclipse/jetty/websocket/core/Extension.java | 6 +++--- .../websocket/core/internal/ExtensionStack.java | 2 +- .../internal/PerMessageDeflateExtension.java | 8 ++++---- .../core/internal/ValidationExtension.java | 16 ++++++++++++++-- .../websocket/core/extensions/ExtensionTool.java | 2 +- .../PerMessageDeflateExtensionTest.java | 10 +++++----- 7 files changed, 34 insertions(+), 22 deletions(-) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java index e3c629d5e67b..2af69bef8e56 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java @@ -26,7 +26,7 @@ import org.eclipse.jetty.util.compression.InflaterPool; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession; +import org.eclipse.jetty.websocket.core.FrameHandler.Configuration; @ManagedObject("Abstract Extension") public class AbstractExtension implements Extension @@ -36,7 +36,7 @@ public class AbstractExtension implements Extension private ExtensionConfig config; private OutgoingFrames nextOutgoing; private IncomingFrames nextIncoming; - private WebSocketCoreSession coreSession; + private Configuration configuration; private DeflaterPool deflaterPool; private InflaterPool inflaterPool; @@ -169,14 +169,14 @@ public void setNextOutgoingFrames(OutgoingFrames nextOutgoing) } @Override - public void setWebSocketCoreSession(WebSocketCoreSession coreSession) + public void setConfiguration(Configuration configuration) { - this.coreSession = coreSession; + this.configuration = configuration; } - protected WebSocketCoreSession getWebSocketCoreSession() + protected Configuration getConfiguration() { - return coreSession; + return configuration; } @Override diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java index 0fd66060372a..0d97a2be44c8 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java @@ -18,7 +18,7 @@ package org.eclipse.jetty.websocket.core; -import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession; +import org.eclipse.jetty.websocket.core.FrameHandler.Configuration; /** * Interface for WebSocket Extensions. @@ -88,7 +88,7 @@ public interface Extension extends IncomingFrames, OutgoingFrames void setNextOutgoingFrames(OutgoingFrames nextOutgoing); /** - * Set the {@link WebSocketCoreSession} for this Extension + * Set the {@link Configuration} for this Extension. */ - void setWebSocketCoreSession(WebSocketCoreSession coreSession); + void setConfiguration(Configuration configuration); } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java index 25f9d799b2e2..e9784c01a609 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java @@ -254,7 +254,7 @@ public void initialize(IncomingFrames incoming, OutgoingFrames outgoing, WebSock for (Extension extension : extensions) { - extension.setWebSocketCoreSession(coreSession); + extension.setConfiguration(coreSession); } } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java index 3e79d9332857..90e333c9c105 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java @@ -269,7 +269,7 @@ protected boolean transform(Callback callback) private boolean deflate(Callback callback) { // Get a buffer for the inflated payload. - long maxFrameSize = getWebSocketCoreSession().getMaxFrameSize(); + long maxFrameSize = getConfiguration().getMaxFrameSize(); int bufferSize = (maxFrameSize <= 0) ? deflateBufferSize : (int)Math.min(maxFrameSize, deflateBufferSize); final ByteBuffer buffer = getBufferPool().acquire(bufferSize, false); callback = Callback.from(callback, () -> getBufferPool().release(buffer)); @@ -289,7 +289,7 @@ private boolean deflate(Callback callback) if (buffer.limit() == bufferSize) { // We need to fragment. TODO: what if there was only bufferSize of content? - if (!getWebSocketCoreSession().isAutoFragment()) + if (!getConfiguration().isAutoFragment()) throw new MessageTooLargeException("Deflated payload exceeded the compress buffer size"); break; } @@ -402,7 +402,7 @@ protected boolean transform(Callback callback) private boolean inflate(Callback callback) throws DataFormatException { // Get a buffer for the inflated payload. - long maxFrameSize = getWebSocketCoreSession().getMaxFrameSize(); + long maxFrameSize = getConfiguration().getMaxFrameSize(); int bufferSize = (maxFrameSize <= 0) ? inflateBufferSize : (int)Math.min(maxFrameSize, inflateBufferSize); final ByteBuffer payload = getBufferPool().acquire(bufferSize, false); callback = Callback.from(callback, () -> getBufferPool().release(payload)); @@ -421,7 +421,7 @@ private boolean inflate(Callback callback) throws DataFormatException if (payload.limit() == bufferSize) { // We need to fragment. TODO: what if there was only bufferSize of content? - if (!getWebSocketCoreSession().isAutoFragment()) + if (!getConfiguration().isAutoFragment()) throw new MessageTooLargeException("Inflated payload exceeded the decompress buffer size"); break; } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java index 496ea84eb162..bbce3306a04f 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java @@ -26,6 +26,7 @@ import org.eclipse.jetty.websocket.core.AbstractExtension; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; +import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.NullAppendable; import org.eclipse.jetty.websocket.core.ProtocolException; import org.eclipse.jetty.websocket.core.WebSocketComponents; @@ -38,6 +39,7 @@ public class ValidationExtension extends AbstractExtension { private static final Logger LOG = Log.getLogger(ValidationExtension.class); + private WebSocketCoreSession coreSession; private FrameSequence incomingSequence = null; private FrameSequence outgoingSequence = null; private boolean incomingFrameValidation = false; @@ -53,6 +55,16 @@ public String getName() return "@validation"; } + @Override + public void setConfiguration(FrameHandler.Configuration configuration) + { + super.setConfiguration(configuration); + + if (!(configuration instanceof WebSocketCoreSession)) + throw new IllegalArgumentException("ValidationExtension needs a CoreSession Configuration"); + coreSession = (WebSocketCoreSession)configuration; + } + @Override public void onFrame(Frame frame, Callback callback) { @@ -62,7 +74,7 @@ public void onFrame(Frame frame, Callback callback) incomingSequence.check(frame.getOpCode(), frame.isFin()); if (incomingFrameValidation) - getWebSocketCoreSession().assertValidIncoming(frame); + coreSession.assertValidIncoming(frame); if (incomingUtf8Validation != null) validateUTF8(frame, incomingUtf8Validation, continuedInOpCode); @@ -85,7 +97,7 @@ public void sendFrame(Frame frame, Callback callback, boolean batch) outgoingSequence.check(frame.getOpCode(), frame.isFin()); if (outgoingFrameValidation) - getWebSocketCoreSession().assertValidOutgoing(frame); + coreSession.assertValidOutgoing(frame); if (outgoingUtf8Validation != null) validateUTF8(frame, outgoingUtf8Validation, continuedOutOpCode); diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java index 890038716e1e..b398cb3725b8 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java @@ -77,7 +77,7 @@ public void assertNegotiated(String expectedNegotiation) { this.ext = components.getExtensionRegistry().newInstance(extConfig, components); this.ext.setNextIncomingFrames(capture); - this.ext.setWebSocketCoreSession(newWebSocketCoreSession()); + this.ext.setConfiguration(newWebSocketCoreSession()); } public void parseIncomingHex(String... rawhex) diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java index 4366bff8d3fd..01f8ca30b5e4 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java @@ -135,7 +135,7 @@ public void testDraft21SharingL77SlidingWindowContextTakeover() tester.assertNegotiated("permessage-deflate"); - tester.parseIncomingHex( // context takeover (2 messages) + tester.parseIncomingHex(// context takeover (2 messages) // message 1 "0xc1 0x07", // (HEADER added for this test) "0xf2 0x48 0xcd 0xc9 0xc9 0x07 0x00", @@ -376,7 +376,7 @@ public void testIncomingFrameNoPayload() PerMessageDeflateExtension ext = new PerMessageDeflateExtension(); ExtensionConfig config = ExtensionConfig.parse("permessage-deflate"); ext.init(config, components); - ext.setWebSocketCoreSession(newSession()); + ext.setConfiguration(newSession()); // Setup capture of incoming frames IncomingFramesCapture capture = new IncomingFramesCapture(); @@ -450,7 +450,7 @@ public void testOutgoingFragmentedMessage() throws IOException, InterruptedExcep { PerMessageDeflateExtension ext = new PerMessageDeflateExtension(); ext.init(ExtensionConfig.parse("permessage-deflate"), components); - ext.setWebSocketCoreSession(newSession()); + ext.setConfiguration(newSession()); // Setup capture of outgoing frames OutgoingFramesCapture capture = new OutgoingFramesCapture(); @@ -497,7 +497,7 @@ public void testOutgoingFrameNoPayload() PerMessageDeflateExtension ext = new PerMessageDeflateExtension(); ExtensionConfig config = ExtensionConfig.parse("permessage-deflate"); ext.init(config, components); - ext.setWebSocketCoreSession(newSession()); + ext.setConfiguration(newSession()); // Setup capture of incoming frames OutgoingFramesCapture capture = new OutgoingFramesCapture(); @@ -548,7 +548,7 @@ public void testPyWebSocketClientToraToraTora() // Captured from Pywebsocket (r790) - "tora" sent 3 times. - tester.parseIncomingHex( // context takeover (3 messages) + tester.parseIncomingHex(// context takeover (3 messages) "c1 06 2a c9 2f 4a 04 00", // tora 1 "c1 05 2a 01 62 00 00", // tora 2 "c1 04 02 61 00 00" // tora 3 From cf31ab2b9a642a574cf17ecb7b3c49b1d198404d Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Mon, 30 Dec 2019 13:38:05 +1100 Subject: [PATCH 02/12] Issue #4450 - don't expose ExtensionStack through getter on Negotation Signed-off-by: Lachlan Roberts --- .../websocket/core/server/Negotiation.java | 19 ------------------- .../server/internal/AbstractHandshaker.java | 13 ++++++++++--- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java index e7c46ac9d7f5..8ded5db63160 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java @@ -31,7 +31,6 @@ import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.QuotedCSV; import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.websocket.core.Behavior; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.internal.ExtensionStack; @@ -184,24 +183,6 @@ public void setNegotiatedExtensions(List extensions) extensionStack = null; } - public ExtensionStack getExtensionStack() - { - if (extensionStack == null) - { - // Extension stack can decide to drop any of these extensions or their parameters - extensionStack = new ExtensionStack(components, Behavior.SERVER); - extensionStack.negotiate(offeredExtensions, negotiatedExtensions); - negotiatedExtensions = extensionStack.getNegotiatedExtensions(); - - if (extensionStack.hasNegotiatedExtensions()) - baseRequest.getResponse().setHeader(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, - ExtensionConfig.toHeaderValue(negotiatedExtensions)); - else - baseRequest.getResponse().setHeader(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, null); - } - return extensionStack; - } - @Override public String toString() { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java index 6647862e8177..61c6b2e3c589 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java @@ -62,7 +62,8 @@ public boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest if (!validateRequest(request)) return false; - Negotiation negotiation = newNegotiation(request, response, negotiator.getWebSocketComponents()); + WebSocketComponents components = negotiator.getWebSocketComponents(); + Negotiation negotiation = newNegotiation(request, response, components); if (LOG.isDebugEnabled()) LOG.debug("negotiation {}", negotiation); negotiation.negotiate(); @@ -123,8 +124,14 @@ public boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest throw new WebSocketException("Upgrade failed: multiple negotiated extensions of the same name"); } - // Create and Negotiate the ExtensionStack - ExtensionStack extensionStack = negotiation.getExtensionStack(); + // Create and Negotiate the ExtensionStack. (ExtensionStack can drop any extensions or their parameters.) + ExtensionStack extensionStack = new ExtensionStack(components, Behavior.SERVER); + extensionStack.negotiate(negotiation.getOfferedExtensions(), negotiation.getNegotiatedExtensions()); + negotiation.setNegotiatedExtensions(extensionStack.getNegotiatedExtensions()); + if (extensionStack.hasNegotiatedExtensions()) + baseRequest.getResponse().setHeader(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, ExtensionConfig.toHeaderValue(negotiation.getNegotiatedExtensions())); + else + baseRequest.getResponse().setHeader(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, null); Negotiated negotiated = new Negotiated(baseRequest.getHttpURI().toURI(), protocol, baseRequest.isSecure(), extensionStack, WebSocketConstants.SPEC_VERSION_STRING); From f1838c5f88b0931d090b74bf1da7a3477faa91cb Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Mon, 30 Dec 2019 13:50:00 +1100 Subject: [PATCH 03/12] Issue #4450 - remove methods to create WS CoreSession and Connection Signed-off-by: Lachlan Roberts --- .../core/client/ClientUpgradeRequest.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) 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 aacafa94ddbb..566f9961d877 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 @@ -26,7 +26,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -44,14 +43,12 @@ import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpVersion; -import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.QuotedStringTokenizer; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.websocket.core.Behavior; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.FrameHandler; @@ -272,16 +269,6 @@ protected void customize(EndPoint endPoint) { } - protected WebSocketConnection newWebSocketConnection(EndPoint endPoint, Executor executor, Scheduler scheduler, ByteBufferPool byteBufferPool, WebSocketCoreSession coreSession) - { - return new WebSocketConnection(endPoint, executor, scheduler, byteBufferPool, coreSession); - } - - protected WebSocketCoreSession newWebSocketCoreSession(FrameHandler handler, Negotiated negotiated) - { - return new WebSocketCoreSession(handler, Behavior.CLIENT, negotiated); - } - public abstract FrameHandler getFrameHandler(); void requestComplete() @@ -436,11 +423,11 @@ else if (values.length == 1) extensionStack, WebSocketConstants.SPEC_VERSION_STRING); - WebSocketCoreSession coreSession = newWebSocketCoreSession(frameHandler, negotiated); + WebSocketCoreSession coreSession = new WebSocketCoreSession(frameHandler, Behavior.CLIENT, negotiated); customizer.customize(coreSession); HttpClient httpClient = wsClient.getHttpClient(); - WebSocketConnection wsConnection = newWebSocketConnection(endPoint, httpClient.getExecutor(), httpClient.getScheduler(), httpClient.getByteBufferPool(), coreSession); + WebSocketConnection wsConnection = new WebSocketConnection(endPoint, httpClient.getExecutor(), httpClient.getScheduler(), httpClient.getByteBufferPool(), coreSession); wsClient.getEventListeners().forEach(wsConnection::addEventListener); coreSession.setWebSocketConnection(wsConnection); notifyUpgradeListeners((listener) -> listener.onHandshakeResponse(this, response)); From 356e98f73713fdb49f72d83cf31849b98bb3c957 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Mon, 30 Dec 2019 15:41:02 +1100 Subject: [PATCH 04/12] Clean up websocket-core package structure Signed-off-by: Lachlan Roberts --- .../src/main/java/module-info.java | 1 + .../websocket/core/AbstractExtension.java | 1 - .../jetty/websocket/core/CloseStatus.java | 3 + .../jetty/websocket/core/Configuration.java | 221 +++++++++ .../jetty/websocket/core/CoreSession.java | 266 +++++++++++ .../jetty/websocket/core/Extension.java | 2 - .../jetty/websocket/core/FrameHandler.java | 447 ------------------ .../jetty/websocket/core/MessageHandler.java | 4 +- .../core/client/ClientUpgradeRequest.java | 14 +- .../core/client/WebSocketCoreClient.java | 5 +- .../{ => exception}/BadPayloadException.java | 4 +- .../core/{ => exception}/CloseException.java | 2 +- .../MessageTooLargeException.java | 4 +- .../{ => exception}/ProtocolException.java | 4 +- .../{ => exception}/UpgradeException.java | 2 +- .../{ => exception}/WebSocketException.java | 2 +- .../WebSocketTimeoutException.java | 2 +- .../WebSocketWriteTimeoutException.java | 2 +- .../core/internal/ExtensionStack.java | 2 +- .../core/internal/FragmentExtension.java | 4 +- .../core/internal/FragmentingFlusher.java | 2 +- .../websocket/core/internal/FrameFlusher.java | 4 +- .../core/internal/FrameSequence.java | 2 +- .../core/{ => internal}/NullAppendable.java | 2 +- .../jetty/websocket/core/internal/Parser.java | 10 +- .../internal/PerMessageDeflateExtension.java | 6 +- .../core/internal/ValidationExtension.java | 7 +- .../core/internal/WebSocketConnection.java | 2 +- .../core/internal/WebSocketCoreSession.java | 16 +- .../core/internal/WebSocketSessionState.java | 2 +- .../websocket/core/server/Handshaker.java | 4 +- .../core/server/WebSocketNegotiator.java | 15 +- .../server/internal/AbstractHandshaker.java | 5 +- .../server/internal/HandshakerSelector.java | 4 +- .../websocket/core/AutoFragmentTest.java | 10 +- .../jetty/websocket/core/FrameBufferTest.java | 1 - .../core/GeneratorFrameFlagsTest.java | 1 + .../jetty/websocket/core/GeneratorTest.java | 2 + .../websocket/core/MessageHandlerTest.java | 3 +- .../jetty/websocket/core/OpCodeTest.java | 1 + .../core/ParserBadCloseStatusCodesTest.java | 1 + .../websocket/core/ParserBadOpCodesTest.java | 1 + .../websocket/core/ParserReservedBitTest.java | 1 + .../jetty/websocket/core/ParserTest.java | 2 + .../core/TestWebSocketNegotiator.java | 2 +- .../core/WebSocketNegotiationTest.java | 2 +- .../websocket/core/WebSocketOpenTest.java | 6 +- .../core/autobahn/AutobahnFrameHandler.java | 1 + .../core/autobahn/CoreAutobahnClient.java | 10 +- .../core/chat/ChatWebSocketServer.java | 1 + .../client/WebSocketClientServerTest.java | 2 +- .../PerMessageDeflateExtensionTest.java | 4 +- .../PerMessageDeflaterBufferSizeTest.java | 9 +- .../core/internal/FrameFlusherTest.java | 2 +- .../websocket/core/proxy/WebSocketProxy.java | 1 + .../core/proxy/WebSocketProxyTest.java | 8 +- .../core/server/WebSocketServerTest.java | 1 + .../common/InvalidWebSocketException.java | 2 +- .../common/JavaxWebSocketAsyncRemote.java | 4 +- .../common/JavaxWebSocketBasicRemote.java | 4 +- .../javax/common/JavaxWebSocketContainer.java | 4 +- .../common/JavaxWebSocketFrameHandler.java | 5 +- .../common/JavaxWebSocketRemoteEndpoint.java | 8 +- .../javax/common/JavaxWebSocketSession.java | 8 +- .../common/messages/ByteArrayMessageSink.java | 2 +- .../messages/ByteBufferMessageSink.java | 2 +- .../messages/DecodedBinaryMessageSink.java | 2 +- .../DecodedBinaryStreamMessageSink.java | 2 +- .../messages/DecodedTextMessageSink.java | 2 +- .../DecodedTextStreamMessageSink.java | 2 +- .../common/messages/MessageOutputStream.java | 6 +- .../javax/common/messages/MessageWriter.java | 6 +- .../common/messages/StringMessageSink.java | 2 +- ...bstractJavaxWebSocketFrameHandlerTest.java | 4 +- .../javax/common/AbstractSessionTest.java | 4 +- .../common/messages/MessageWriterTest.java | 6 +- .../JavaxWebSocketServerContainer.java | 2 +- .../websocket/javax/tests/CoreServer.java | 5 +- .../websocket/javax/tests/NetworkFuzzer.java | 3 +- .../javax/tests/framehandlers/FrameEcho.java | 1 + .../framehandlers/FrameHandlerTracker.java | 1 + .../websocket/IdleTimeoutOnOpenSocket.java | 2 +- .../client/AbstractClientSessionTest.java | 4 +- .../tests/client/MessageReceivingTest.java | 3 +- .../javax/tests/client/OnCloseTest.java | 4 +- .../client/SessionAddMessageHandlerTest.java | 4 +- .../javax/tests/client/WriteTimeoutTest.java | 2 +- .../javax/tests/server/ConfiguratorTest.java | 38 +- .../tests/server/EndpointViaConfigTest.java | 6 +- ...FrameHandler_OnMessage_TextStreamTest.java | 4 +- .../tests/server/LargeAnnotatedTest.java | 6 +- .../tests/server/LargeContainerTest.java | 6 +- .../tests/server/OnMessageReturnTest.java | 6 +- .../javax/tests/server/PingPongTest.java | 8 +- .../sockets/IdleTimeoutOnOpenSocket.java | 2 +- .../websocket/client/WebSocketClient.java | 4 +- .../common/FunctionCallException.java | 2 +- .../common/JettyWebSocketFrameHandler.java | 20 +- .../JettyWebSocketFrameHandlerMetadata.java | 4 +- .../common/JettyWebSocketRemoteEndpoint.java | 10 +- .../websocket/common/WebSocketSession.java | 8 +- .../common/message/ByteArrayMessageSink.java | 2 +- .../common/message/ByteBufferMessageSink.java | 2 +- .../common/message/MessageOutputStream.java | 6 +- .../common/message/MessageWriter.java | 6 +- .../common/message/StringMessageSink.java | 2 +- .../JettyWebSocketFrameHandlerTest.java | 4 +- .../common/OutgoingMessageCapture.java | 4 +- .../server/JettyWebSocketServerContainer.java | 6 +- .../tests/client/ClientConnectTest.java | 2 +- .../websocket/servlet/WebSocketMapping.java | 16 +- .../websocket/servlet/WebSocketServlet.java | 4 +- .../servlet/WebSocketServletFactory.java | 4 +- .../servlet/WebSocketUpgradeFilter.java | 4 +- 114 files changed, 758 insertions(+), 679 deletions(-) create mode 100644 jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java create mode 100644 jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java rename jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/{ => exception}/BadPayloadException.java (93%) rename jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/{ => exception}/CloseException.java (96%) rename jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/{ => exception}/MessageTooLargeException.java (93%) rename jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/{ => exception}/ProtocolException.java (92%) rename jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/{ => exception}/UpgradeException.java (97%) rename jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/{ => exception}/WebSocketException.java (96%) rename jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/{ => exception}/WebSocketTimeoutException.java (96%) rename jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/{ => exception}/WebSocketWriteTimeoutException.java (94%) rename jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/{ => internal}/NullAppendable.java (96%) diff --git a/jetty-websocket/websocket-core/src/main/java/module-info.java b/jetty-websocket/websocket-core/src/main/java/module-info.java index e028f5240298..038b9931667e 100644 --- a/jetty-websocket/websocket-core/src/main/java/module-info.java +++ b/jetty-websocket/websocket-core/src/main/java/module-info.java @@ -27,6 +27,7 @@ exports org.eclipse.jetty.websocket.core; exports org.eclipse.jetty.websocket.core.client; exports org.eclipse.jetty.websocket.core.server; + exports org.eclipse.jetty.websocket.core.exception; exports org.eclipse.jetty.websocket.core.internal to org.eclipse.jetty.util; requires jetty.servlet.api; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java index 2af69bef8e56..7a0a18cddfc3 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java @@ -26,7 +26,6 @@ import org.eclipse.jetty.util.compression.InflaterPool; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.websocket.core.FrameHandler.Configuration; @ManagedObject("Abstract Extension") public class AbstractExtension implements Extension diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CloseStatus.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CloseStatus.java index e3661992a2aa..5ef5617a2635 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CloseStatus.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CloseStatus.java @@ -25,6 +25,9 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Utf8Appendable; import org.eclipse.jetty.util.Utf8StringBuilder; +import org.eclipse.jetty.websocket.core.exception.BadPayloadException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; +import org.eclipse.jetty.websocket.core.internal.NullAppendable; /** * Representation of a WebSocket Close (status code & reason) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java new file mode 100644 index 000000000000..09502df70778 --- /dev/null +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java @@ -0,0 +1,221 @@ +// +// ======================================================================== +// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.websocket.core; + +import java.time.Duration; + +public interface Configuration +{ + /** + * Get the Idle Timeout + * + * @return the idle timeout + */ + Duration getIdleTimeout(); + + /** + * Get the Write Timeout + * + * @return the write timeout + */ + Duration getWriteTimeout(); + + /** + * Set the Idle Timeout. + * + * @param timeout the timeout duration (timeout <= 0 implies an infinite timeout) + */ + void setIdleTimeout(Duration timeout); + + /** + * Set the Write Timeout. + * + * @param timeout the timeout duration (timeout <= 0 implies an infinite timeout) + */ + void setWriteTimeout(Duration timeout); + + boolean isAutoFragment(); + + void setAutoFragment(boolean autoFragment); + + long getMaxFrameSize(); + + void setMaxFrameSize(long maxFrameSize); + + int getOutputBufferSize(); + + void setOutputBufferSize(int outputBufferSize); + + int getInputBufferSize(); + + void setInputBufferSize(int inputBufferSize); + + long getMaxBinaryMessageSize(); + + void setMaxBinaryMessageSize(long maxSize); + + long getMaxTextMessageSize(); + + void setMaxTextMessageSize(long maxSize); + + interface Customizer + { + void customize(Configuration configurable); + } + + class ConfigurationHolder implements Configuration + { + protected Duration idleTimeout; + protected Duration writeTimeout; + protected Boolean autoFragment; + protected Long maxFrameSize; + protected Integer outputBufferSize; + protected Integer inputBufferSize; + protected Long maxBinaryMessageSize; + protected Long maxTextMessageSize; + + @Override + public Duration getIdleTimeout() + { + return idleTimeout == null ? WebSocketConstants.DEFAULT_IDLE_TIMEOUT : idleTimeout; + } + + @Override + public Duration getWriteTimeout() + { + return writeTimeout == null ? WebSocketConstants.DEFAULT_WRITE_TIMEOUT : writeTimeout; + } + + @Override + public void setIdleTimeout(Duration timeout) + { + this.idleTimeout = timeout; + } + + @Override + public void setWriteTimeout(Duration timeout) + { + this.writeTimeout = timeout; + } + + @Override + public boolean isAutoFragment() + { + return autoFragment == null ? WebSocketConstants.DEFAULT_AUTO_FRAGMENT : autoFragment; + } + + @Override + public void setAutoFragment(boolean autoFragment) + { + this.autoFragment = autoFragment; + } + + @Override + public long getMaxFrameSize() + { + return maxFrameSize == null ? WebSocketConstants.DEFAULT_MAX_FRAME_SIZE : maxFrameSize; + } + + @Override + public void setMaxFrameSize(long maxFrameSize) + { + this.maxFrameSize = maxFrameSize; + } + + @Override + public int getOutputBufferSize() + { + return outputBufferSize == null ? WebSocketConstants.DEFAULT_OUTPUT_BUFFER_SIZE : outputBufferSize; + } + + @Override + public void setOutputBufferSize(int outputBufferSize) + { + this.outputBufferSize = outputBufferSize; + } + + @Override + public int getInputBufferSize() + { + return inputBufferSize == null ? WebSocketConstants.DEFAULT_INPUT_BUFFER_SIZE : inputBufferSize; + } + + @Override + public void setInputBufferSize(int inputBufferSize) + { + this.inputBufferSize = inputBufferSize; + } + + @Override + public long getMaxBinaryMessageSize() + { + return maxBinaryMessageSize == null ? WebSocketConstants.DEFAULT_MAX_BINARY_MESSAGE_SIZE : maxBinaryMessageSize; + } + + @Override + public void setMaxBinaryMessageSize(long maxBinaryMessageSize) + { + this.maxBinaryMessageSize = maxBinaryMessageSize; + } + + @Override + public long getMaxTextMessageSize() + { + return maxTextMessageSize == null ? WebSocketConstants.DEFAULT_MAX_TEXT_MESSAGE_SIZE : maxTextMessageSize; + } + + @Override + public void setMaxTextMessageSize(long maxTextMessageSize) + { + this.maxTextMessageSize = maxTextMessageSize; + } + } + + class ConfigurationCustomizer extends ConfigurationHolder implements Customizer + { + @Override + public void customize(Configuration configurable) + { + if (idleTimeout != null) + configurable.setIdleTimeout(idleTimeout); + if (writeTimeout != null) + configurable.setWriteTimeout(writeTimeout); + if (autoFragment != null) + configurable.setAutoFragment(autoFragment); + if (maxFrameSize != null) + configurable.setMaxFrameSize(maxFrameSize); + if (inputBufferSize != null) + configurable.setInputBufferSize(inputBufferSize); + if (outputBufferSize != null) + configurable.setOutputBufferSize(outputBufferSize); + if (maxBinaryMessageSize != null) + configurable.setMaxBinaryMessageSize(maxBinaryMessageSize); + if (maxTextMessageSize != null) + configurable.setMaxTextMessageSize(maxTextMessageSize); + } + + public static ConfigurationCustomizer from(ConfigurationCustomizer parent, ConfigurationCustomizer child) + { + ConfigurationCustomizer customizer = new ConfigurationCustomizer(); + parent.customize(customizer); + child.customize(customizer); + return customizer; + } + } +} diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java new file mode 100644 index 000000000000..7104323e60a9 --- /dev/null +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java @@ -0,0 +1,266 @@ +// +// ======================================================================== +// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.websocket.core; + +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.net.URI; +import java.util.List; +import java.util.Map; + +import org.eclipse.jetty.io.ByteBufferPool; +import org.eclipse.jetty.util.Callback; + +/** + * Represents the outgoing Frames. + */ +public interface CoreSession extends OutgoingFrames, Configuration +{ + /** + * The negotiated WebSocket Sub-Protocol for this session. + * + * @return the negotiated WebSocket Sub-Protocol for this session. + */ + String getNegotiatedSubProtocol(); + + /** + * The negotiated WebSocket Extension Configurations for this session. + * + * @return the list of Negotiated Extension Configurations for this session. + */ + List getNegotiatedExtensions(); + + /** + * The parameter map (from URI Query) for the active session. + * + * @return the immutable map of parameters + */ + Map> getParameterMap(); + + /** + * The active {@code Sec-WebSocket-Version} (protocol version) in use. + * + * @return the protocol version in use. + */ + String getProtocolVersion(); + + /** + * The active connection's Request URI. + * This is the URI of the upgrade request and is typically http: or https: rather than + * the ws: or wss: scheme. + * + * @return the absolute URI (including Query string) + */ + URI getRequestURI(); + + /** + * The active connection's Secure status indicator. + * + * @return true if connection is secure (similar in role to {@code HttpServletRequest.isSecure()}) + */ + boolean isSecure(); + + /** + * @return Client or Server behaviour + */ + Behavior getBehavior(); + + /** + * @return The shared ByteBufferPool + */ + ByteBufferPool getByteBufferPool(); + + /** + * The Local Socket Address for the connection + *

+ * Do not assume that this will return a {@link InetSocketAddress} in all cases. + * Use of various proxies, and even UnixSockets can result a SocketAddress being returned + * without supporting {@link InetSocketAddress} + *

+ * + * @return the SocketAddress for the local connection, or null if not supported by Session + */ + SocketAddress getLocalAddress(); + + /** + * The Remote Socket Address for the connection + *

+ * Do not assume that this will return a {@link InetSocketAddress} in all cases. + * Use of various proxies, and even UnixSockets can result a SocketAddress being returned + * without supporting {@link InetSocketAddress} + *

+ * + * @return the SocketAddress for the remote connection, or null if not supported by Session + */ + SocketAddress getRemoteAddress(); + + /** + * @return True if the websocket is open outbound + */ + boolean isOutputOpen(); + + /** + * If using BatchMode.ON or BatchMode.AUTO, trigger a flush of enqueued / batched frames. + * + * @param callback the callback to track close frame sent (or failed) + */ + void flush(Callback callback); + + /** + * Initiate close handshake, no payload (no declared status code or reason phrase) + * + * @param callback the callback to track close frame sent (or failed) + */ + void close(Callback callback); + + /** + * Initiate close handshake with provide status code and optional reason phrase. + * + * @param statusCode the status code (should be a valid status code that can be sent) + * @param reason optional reason phrase (will be truncated automatically by implementation to fit within limits of protocol) + * @param callback the callback to track close frame sent (or failed) + */ + void close(int statusCode, String reason, Callback callback); + + /** + * Issue a harsh abort of the underlying connection. + *

+ * This will terminate the connection, without sending a websocket close frame. + * No WebSocket Protocol close handshake will be performed. + *

+ *

+ * Once called, any read/write activity on the websocket from this point will be indeterminate. + * This can result in the {@link FrameHandler#onError(Throwable, Callback)} event being called indicating any issue that arises. + *

+ *

+ * Once the underlying connection has been determined to be closed, the {@link FrameHandler#onClosed(CloseStatus, Callback)} event will be called. + *

+ */ + void abort(); + + /** + * Manage flow control by indicating demand for handling Frames. A call to + * {@link FrameHandler#onFrame(Frame, Callback)} will only be made if a + * corresponding demand has been signaled. It is an error to call this method + * if {@link FrameHandler#isDemanding()} returns false. + * + * @param n The number of frames that can be handled (in sequential calls to + * {@link FrameHandler#onFrame(Frame, Callback)}). May not be negative. + */ + void demand(long n); + + class Empty extends ConfigurationCustomizer implements CoreSession + { + @Override + public String getNegotiatedSubProtocol() + { + return null; + } + + @Override + public List getNegotiatedExtensions() + { + return null; + } + + @Override + public Map> getParameterMap() + { + return null; + } + + @Override + public String getProtocolVersion() + { + return null; + } + + @Override + public URI getRequestURI() + { + return null; + } + + @Override + public boolean isSecure() + { + return false; + } + + @Override + public void abort() + { + } + + @Override + public Behavior getBehavior() + { + return null; + } + + @Override + public ByteBufferPool getByteBufferPool() + { + return null; + } + + @Override + public SocketAddress getLocalAddress() + { + return null; + } + + @Override + public SocketAddress getRemoteAddress() + { + return null; + } + + @Override + public boolean isOutputOpen() + { + return false; + } + + @Override + public void flush(Callback callback) + { + } + + @Override + public void close(Callback callback) + { + } + + @Override + public void close(int statusCode, String reason, Callback callback) + { + } + + @Override + public void demand(long n) + { + } + + @Override + public void sendFrame(Frame frame, Callback callback, boolean batch) + { + } + } +} diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java index 0d97a2be44c8..2bbab07de88e 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java @@ -18,8 +18,6 @@ package org.eclipse.jetty.websocket.core; -import org.eclipse.jetty.websocket.core.FrameHandler.Configuration; - /** * Interface for WebSocket Extensions. *

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 16fd5bcc3a15..37b3f9181b63 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 @@ -18,14 +18,6 @@ package org.eclipse.jetty.websocket.core; -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import java.net.URI; -import java.time.Duration; -import java.util.List; -import java.util.Map; - -import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.core.server.Negotiation; @@ -129,443 +121,4 @@ default boolean isDemanding() { return false; } - - interface Configuration - { - - /** - * Get the Idle Timeout - * - * @return the idle timeout - */ - Duration getIdleTimeout(); - - /** - * Get the Write Timeout - * - * @return the write timeout - */ - Duration getWriteTimeout(); - - /** - * Set the Idle Timeout. - * - * @param timeout the timeout duration (timeout <= 0 implies an infinite timeout) - */ - void setIdleTimeout(Duration timeout); - - /** - * Set the Write Timeout. - * - * @param timeout the timeout duration (timeout <= 0 implies an infinite timeout) - */ - void setWriteTimeout(Duration timeout); - - boolean isAutoFragment(); - - void setAutoFragment(boolean autoFragment); - - long getMaxFrameSize(); - - void setMaxFrameSize(long maxFrameSize); - - int getOutputBufferSize(); - - void setOutputBufferSize(int outputBufferSize); - - int getInputBufferSize(); - - void setInputBufferSize(int inputBufferSize); - - long getMaxBinaryMessageSize(); - - void setMaxBinaryMessageSize(long maxSize); - - long getMaxTextMessageSize(); - - void setMaxTextMessageSize(long maxSize); - } - - /** - * Represents the outgoing Frames. - */ - interface CoreSession extends OutgoingFrames, Configuration - { - /** - * The negotiated WebSocket Sub-Protocol for this session. - * - * @return the negotiated WebSocket Sub-Protocol for this session. - */ - String getNegotiatedSubProtocol(); - - /** - * The negotiated WebSocket Extension Configurations for this session. - * - * @return the list of Negotiated Extension Configurations for this session. - */ - List getNegotiatedExtensions(); - - /** - * The parameter map (from URI Query) for the active session. - * - * @return the immutable map of parameters - */ - Map> getParameterMap(); - - /** - * The active {@code Sec-WebSocket-Version} (protocol version) in use. - * - * @return the protocol version in use. - */ - String getProtocolVersion(); - - /** - * The active connection's Request URI. - * This is the URI of the upgrade request and is typically http: or https: rather than - * the ws: or wss: scheme. - * - * @return the absolute URI (including Query string) - */ - URI getRequestURI(); - - /** - * The active connection's Secure status indicator. - * - * @return true if connection is secure (similar in role to {@code HttpServletRequest.isSecure()}) - */ - boolean isSecure(); - - /** - * @return Client or Server behaviour - */ - Behavior getBehavior(); - - /** - * @return The shared ByteBufferPool - */ - ByteBufferPool getByteBufferPool(); - - /** - * The Local Socket Address for the connection - *

- * Do not assume that this will return a {@link InetSocketAddress} in all cases. - * Use of various proxies, and even UnixSockets can result a SocketAddress being returned - * without supporting {@link InetSocketAddress} - *

- * - * @return the SocketAddress for the local connection, or null if not supported by Session - */ - SocketAddress getLocalAddress(); - - /** - * The Remote Socket Address for the connection - *

- * Do not assume that this will return a {@link InetSocketAddress} in all cases. - * Use of various proxies, and even UnixSockets can result a SocketAddress being returned - * without supporting {@link InetSocketAddress} - *

- * - * @return the SocketAddress for the remote connection, or null if not supported by Session - */ - SocketAddress getRemoteAddress(); - - /** - * @return True if the websocket is open outbound - */ - boolean isOutputOpen(); - - /** - * If using BatchMode.ON or BatchMode.AUTO, trigger a flush of enqueued / batched frames. - * - * @param callback the callback to track close frame sent (or failed) - */ - void flush(Callback callback); - - /** - * Initiate close handshake, no payload (no declared status code or reason phrase) - * - * @param callback the callback to track close frame sent (or failed) - */ - void close(Callback callback); - - /** - * Initiate close handshake with provide status code and optional reason phrase. - * - * @param statusCode the status code (should be a valid status code that can be sent) - * @param reason optional reason phrase (will be truncated automatically by implementation to fit within limits of protocol) - * @param callback the callback to track close frame sent (or failed) - */ - void close(int statusCode, String reason, Callback callback); - - /** - * Issue a harsh abort of the underlying connection. - *

- * This will terminate the connection, without sending a websocket close frame. - * No WebSocket Protocol close handshake will be performed. - *

- *

- * Once called, any read/write activity on the websocket from this point will be indeterminate. - * This can result in the {@link #onError(Throwable, Callback)} event being called indicating any issue that arises. - *

- *

- * Once the underlying connection has been determined to be closed, the {@link #onClosed(CloseStatus, Callback)} event will be called. - *

- */ - void abort(); - - /** - * Manage flow control by indicating demand for handling Frames. A call to - * {@link FrameHandler#onFrame(Frame, Callback)} will only be made if a - * corresponding demand has been signaled. It is an error to call this method - * if {@link FrameHandler#isDemanding()} returns false. - * - * @param n The number of frames that can be handled (in sequential calls to - * {@link FrameHandler#onFrame(Frame, Callback)}). May not be negative. - */ - void demand(long n); - - class Empty extends ConfigurationCustomizer implements CoreSession - { - @Override - public String getNegotiatedSubProtocol() - { - return null; - } - - @Override - public List getNegotiatedExtensions() - { - return null; - } - - @Override - public Map> getParameterMap() - { - return null; - } - - @Override - public String getProtocolVersion() - { - return null; - } - - @Override - public URI getRequestURI() - { - return null; - } - - @Override - public boolean isSecure() - { - return false; - } - - @Override - public void abort() - { - } - - @Override - public Behavior getBehavior() - { - return null; - } - - @Override - public ByteBufferPool getByteBufferPool() - { - return null; - } - - @Override - public SocketAddress getLocalAddress() - { - return null; - } - - @Override - public SocketAddress getRemoteAddress() - { - return null; - } - - @Override - public boolean isOutputOpen() - { - return false; - } - - @Override - public void flush(Callback callback) - { - } - - @Override - public void close(Callback callback) - { - } - - @Override - public void close(int statusCode, String reason, Callback callback) - { - } - - @Override - public void demand(long n) - { - } - - @Override - public void sendFrame(Frame frame, Callback callback, boolean batch) - { - } - } - } - - interface Customizer - { - void customize(Configuration configurable); - } - - class ConfigurationHolder implements Configuration - { - protected Duration idleTimeout; - protected Duration writeTimeout; - protected Boolean autoFragment; - protected Long maxFrameSize; - protected Integer outputBufferSize; - protected Integer inputBufferSize; - protected Long maxBinaryMessageSize; - protected Long maxTextMessageSize; - - @Override - public Duration getIdleTimeout() - { - return idleTimeout == null ? WebSocketConstants.DEFAULT_IDLE_TIMEOUT : idleTimeout; - } - - @Override - public Duration getWriteTimeout() - { - return writeTimeout == null ? WebSocketConstants.DEFAULT_WRITE_TIMEOUT : writeTimeout; - } - - @Override - public void setIdleTimeout(Duration timeout) - { - this.idleTimeout = timeout; - } - - @Override - public void setWriteTimeout(Duration timeout) - { - this.writeTimeout = timeout; - } - - @Override - public boolean isAutoFragment() - { - return autoFragment == null ? WebSocketConstants.DEFAULT_AUTO_FRAGMENT : autoFragment; - } - - @Override - public void setAutoFragment(boolean autoFragment) - { - this.autoFragment = autoFragment; - } - - @Override - public long getMaxFrameSize() - { - return maxFrameSize == null ? WebSocketConstants.DEFAULT_MAX_FRAME_SIZE : maxFrameSize; - } - - @Override - public void setMaxFrameSize(long maxFrameSize) - { - this.maxFrameSize = maxFrameSize; - } - - @Override - public int getOutputBufferSize() - { - return outputBufferSize == null ? WebSocketConstants.DEFAULT_OUTPUT_BUFFER_SIZE : outputBufferSize; - } - - @Override - public void setOutputBufferSize(int outputBufferSize) - { - this.outputBufferSize = outputBufferSize; - } - - @Override - public int getInputBufferSize() - { - return inputBufferSize == null ? WebSocketConstants.DEFAULT_INPUT_BUFFER_SIZE : inputBufferSize; - } - - @Override - public void setInputBufferSize(int inputBufferSize) - { - this.inputBufferSize = inputBufferSize; - } - - @Override - public long getMaxBinaryMessageSize() - { - return maxBinaryMessageSize == null ? WebSocketConstants.DEFAULT_MAX_BINARY_MESSAGE_SIZE : maxBinaryMessageSize; - } - - @Override - public void setMaxBinaryMessageSize(long maxBinaryMessageSize) - { - this.maxBinaryMessageSize = maxBinaryMessageSize; - } - - @Override - public long getMaxTextMessageSize() - { - return maxTextMessageSize == null ? WebSocketConstants.DEFAULT_MAX_TEXT_MESSAGE_SIZE : maxTextMessageSize; - } - - @Override - public void setMaxTextMessageSize(long maxTextMessageSize) - { - this.maxTextMessageSize = maxTextMessageSize; - } - } - - class ConfigurationCustomizer extends ConfigurationHolder implements Customizer - { - @Override - public void customize(Configuration configurable) - { - if (idleTimeout != null) - configurable.setIdleTimeout(idleTimeout); - if (writeTimeout != null) - configurable.setWriteTimeout(idleTimeout); - if (autoFragment != null) - configurable.setAutoFragment(autoFragment); - if (maxFrameSize != null) - configurable.setMaxFrameSize(maxFrameSize); - if (inputBufferSize != null) - configurable.setInputBufferSize(inputBufferSize); - if (outputBufferSize != null) - configurable.setOutputBufferSize(outputBufferSize); - if (maxBinaryMessageSize != null) - configurable.setMaxBinaryMessageSize(maxBinaryMessageSize); - if (maxTextMessageSize != null) - configurable.setMaxTextMessageSize(maxTextMessageSize); - } - - public static ConfigurationCustomizer from(ConfigurationCustomizer parent, ConfigurationCustomizer child) - { - ConfigurationCustomizer customizer = new ConfigurationCustomizer(); - parent.customize(customizer); - child.customize(customizer); - return customizer; - } - } } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java index 86d962b5f2e9..cfd9fe21e64b 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java @@ -29,13 +29,15 @@ import org.eclipse.jetty.util.Utf8StringBuilder; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.exception.BadPayloadException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; /** * A utility implementation of FrameHandler that defragments * text frames into a String message before calling {@link #onText(String, Callback)}. * Flow control is by default automatic, but an implementation * may extend {@link #isDemanding()} to return true and then explicityly control - * demand with calls to {@link org.eclipse.jetty.websocket.core.FrameHandler.CoreSession#demand(long)} + * demand with calls to {@link CoreSession#demand(long)} */ public class MessageHandler implements FrameHandler { 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 566f9961d877..098fb00060b2 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 @@ -50,11 +50,13 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.Behavior; +import org.eclipse.jetty.websocket.core.Configuration; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.UpgradeException; +import org.eclipse.jetty.websocket.core.exception.UpgradeException; import org.eclipse.jetty.websocket.core.WebSocketConstants; -import org.eclipse.jetty.websocket.core.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.core.internal.ExtensionStack; import org.eclipse.jetty.websocket.core.internal.Negotiated; import org.eclipse.jetty.websocket.core.internal.WebSocketConnection; @@ -75,10 +77,10 @@ public FrameHandler getFrameHandler() } private static final Logger LOG = Log.getLogger(ClientUpgradeRequest.class); - protected final CompletableFuture futureCoreSession; + protected final CompletableFuture futureCoreSession; private final WebSocketCoreClient wsClient; private FrameHandler frameHandler; - private FrameHandler.ConfigurationCustomizer customizer = new FrameHandler.ConfigurationCustomizer(); + private Configuration.ConfigurationCustomizer customizer = new Configuration.ConfigurationCustomizer(); private List upgradeListeners = new ArrayList<>(); private List requestedExtensions = new ArrayList<>(); @@ -112,7 +114,7 @@ public ClientUpgradeRequest(WebSocketCoreClient webSocketClient, URI requestURI) this.futureCoreSession = new CompletableFuture<>(); } - public void setConfiguration(FrameHandler.ConfigurationCustomizer config) + public void setConfiguration(Configuration.ConfigurationCustomizer config) { config.customize(customizer); } @@ -187,7 +189,7 @@ public void send(final Response.CompleteListener listener) super.send(listener); } - public CompletableFuture sendAsync() + public CompletableFuture sendAsync() { send(this); return futureCoreSession; 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 1c89cdcc871a..b64223a5e6f4 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 @@ -28,6 +28,7 @@ import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.WebSocketComponents; @@ -68,13 +69,13 @@ public WebSocketCoreClient(HttpClient httpClient, WebSocketComponents webSocketC addBean(httpClient); } - public CompletableFuture connect(FrameHandler frameHandler, URI wsUri) throws IOException + public CompletableFuture connect(FrameHandler frameHandler, URI wsUri) throws IOException { ClientUpgradeRequest request = ClientUpgradeRequest.from(this, wsUri, frameHandler); return connect(request); } - public CompletableFuture connect(ClientUpgradeRequest request) throws IOException + public CompletableFuture connect(ClientUpgradeRequest request) throws IOException { if (!isStarted()) throw new IllegalStateException(WebSocketCoreClient.class.getSimpleName() + "@" + this.hashCode() + " is not started"); diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/BadPayloadException.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/BadPayloadException.java similarity index 93% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/BadPayloadException.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/BadPayloadException.java index d0cfdae380b7..1d1846746153 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/BadPayloadException.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/BadPayloadException.java @@ -16,7 +16,9 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core; +package org.eclipse.jetty.websocket.core.exception; + +import org.eclipse.jetty.websocket.core.CloseStatus; /** * Exception to terminate the connection because it has received data within a frame payload that was not consistent with the requirements of that frame diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CloseException.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/CloseException.java similarity index 96% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CloseException.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/CloseException.java index a28f7a5fb084..e7a85c8ff0f9 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CloseException.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/CloseException.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core; +package org.eclipse.jetty.websocket.core.exception; @SuppressWarnings("serial") public class CloseException extends WebSocketException diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageTooLargeException.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/MessageTooLargeException.java similarity index 93% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageTooLargeException.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/MessageTooLargeException.java index b6e8ff47f481..51bdf3c35b0f 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageTooLargeException.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/MessageTooLargeException.java @@ -16,7 +16,9 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core; +package org.eclipse.jetty.websocket.core.exception; + +import org.eclipse.jetty.websocket.core.CloseStatus; /** * Exception when a message is too large for the internal buffers occurs and should trigger a connection close. diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/ProtocolException.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/ProtocolException.java similarity index 92% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/ProtocolException.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/ProtocolException.java index 9aa97fa98d09..d5d9e1fab598 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/ProtocolException.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/ProtocolException.java @@ -16,7 +16,9 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core; +package org.eclipse.jetty.websocket.core.exception; + +import org.eclipse.jetty.websocket.core.CloseStatus; /** * Per spec, a protocol error should result in a Close frame of status code 1002 (PROTOCOL_ERROR) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/UpgradeException.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/UpgradeException.java similarity index 97% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/UpgradeException.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/UpgradeException.java index 6ad3b78c2005..da4428ebca9c 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/UpgradeException.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/UpgradeException.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core; +package org.eclipse.jetty.websocket.core.exception; import java.net.URI; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketException.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketException.java similarity index 96% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketException.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketException.java index 2da71d2f94d5..1239f1d7e3c6 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketException.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketException.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core; +package org.eclipse.jetty.websocket.core.exception; /** * A recoverable exception within the websocket framework. diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketTimeoutException.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketTimeoutException.java similarity index 96% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketTimeoutException.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketTimeoutException.java index 8dcfab5b1043..4f96a86f9b01 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketTimeoutException.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketTimeoutException.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core; +package org.eclipse.jetty.websocket.core.exception; /** * Exception thrown to indicate a connection I/O timeout. diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketWriteTimeoutException.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketWriteTimeoutException.java similarity index 94% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketWriteTimeoutException.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketWriteTimeoutException.java index 2dabed131339..c4b885e7dd50 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketWriteTimeoutException.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketWriteTimeoutException.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core; +package org.eclipse.jetty.websocket.core.exception; public class WebSocketWriteTimeoutException extends WebSocketTimeoutException { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java index e9784c01a609..2632fb6d264f 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java @@ -39,7 +39,7 @@ import org.eclipse.jetty.websocket.core.IncomingFrames; import org.eclipse.jetty.websocket.core.OutgoingFrames; import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; /** * Represents the stack of Extensions. diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java index 5f481d800d4e..22231c1a9a51 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java @@ -22,9 +22,9 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.AbstractExtension; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.WebSocketComponents; /** @@ -35,7 +35,7 @@ public class FragmentExtension extends AbstractExtension private static final Logger LOG = Log.getLogger(FragmentExtension.class); private final FragmentingFlusher flusher; - private final FrameHandler.Configuration configuration = new FrameHandler.ConfigurationHolder(); + private final Configuration configuration = new Configuration.ConfigurationHolder(); public FragmentExtension() { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java index 520b4c508fb9..464acff2c69d 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java @@ -24,7 +24,7 @@ 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.Configuration; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.OpCode; /** diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java index d9538973363f..ac0169b89cc3 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java @@ -41,8 +41,8 @@ import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.core.WebSocketException; -import org.eclipse.jetty.websocket.core.WebSocketWriteTimeoutException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.WebSocketWriteTimeoutException; public class FrameFlusher extends IteratingCallback { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameSequence.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameSequence.java index 7e2ed5f805a5..812a992abe56 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameSequence.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameSequence.java @@ -19,7 +19,7 @@ package org.eclipse.jetty.websocket.core.internal; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.core.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; public class FrameSequence { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/NullAppendable.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/NullAppendable.java similarity index 96% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/NullAppendable.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/NullAppendable.java index 6dde40e4d7ac..769fed304b27 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/NullAppendable.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/NullAppendable.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core; +package org.eclipse.jetty.websocket.core.internal; import org.eclipse.jetty.util.Utf8Appendable; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java index 486aaaffbbcf..e63e17a8f6a3 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java @@ -28,12 +28,12 @@ import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler.Configuration; -import org.eclipse.jetty.websocket.core.FrameHandler.ConfigurationHolder; -import org.eclipse.jetty.websocket.core.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.Configuration; +import org.eclipse.jetty.websocket.core.Configuration.ConfigurationHolder; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.core.ProtocolException; -import org.eclipse.jetty.websocket.core.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; /** * Parsing of a frames in WebSocket land. diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java index 90e333c9c105..c9fea2a1ea7a 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java @@ -30,12 +30,12 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.AbstractExtension; -import org.eclipse.jetty.websocket.core.BadPayloadException; +import org.eclipse.jetty.websocket.core.exception.BadPayloadException; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.core.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.WebSocketComponents; /** diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java index bbce3306a04f..c2d2689fcaf0 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java @@ -24,11 +24,10 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.AbstractExtension; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.NullAppendable; -import org.eclipse.jetty.websocket.core.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.WebSocketComponents; import static org.eclipse.jetty.websocket.core.OpCode.CONTINUATION; @@ -56,7 +55,7 @@ public String getName() } @Override - public void setConfiguration(FrameHandler.Configuration configuration) + public void setConfiguration(Configuration configuration) { super.setConfiguration(configuration); diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java index 9b7d6766788c..0438cc0199a8 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java @@ -39,7 +39,7 @@ import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.websocket.core.Behavior; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.WebSocketTimeoutException; +import org.eclipse.jetty.websocket.core.exception.WebSocketTimeoutException; /** * Provides the implementation of {@link org.eclipse.jetty.io.Connection} that is suitable for WebSocket diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java index 1ed5fc8590f3..ad76f095f316 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java @@ -36,19 +36,21 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.Behavior; -import org.eclipse.jetty.websocket.core.CloseException; +import org.eclipse.jetty.websocket.core.Configuration; +import org.eclipse.jetty.websocket.core.CoreSession; +import org.eclipse.jetty.websocket.core.exception.CloseException; import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.IncomingFrames; -import org.eclipse.jetty.websocket.core.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.OutgoingFrames; -import org.eclipse.jetty.websocket.core.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.WebSocketConstants; -import org.eclipse.jetty.websocket.core.WebSocketTimeoutException; -import org.eclipse.jetty.websocket.core.WebSocketWriteTimeoutException; +import org.eclipse.jetty.websocket.core.exception.WebSocketTimeoutException; +import org.eclipse.jetty.websocket.core.exception.WebSocketWriteTimeoutException; import org.eclipse.jetty.websocket.core.internal.Parser.ParsedFrame; import static org.eclipse.jetty.util.Callback.NOOP; @@ -56,7 +58,7 @@ /** * The Core WebSocket Session. */ -public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSession, Dumpable +public class WebSocketCoreSession implements IncomingFrames, CoreSession, Dumpable { private static final Logger LOG = Log.getLogger(WebSocketCoreSession.class); private static final CloseStatus NO_CODE = new CloseStatus(CloseStatus.NO_CODE); @@ -809,7 +811,7 @@ public String toString() private class Flusher extends FragmentingFlusher { - public Flusher(FrameHandler.Configuration configuration) + public Flusher(Configuration configuration) { super(configuration); } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketSessionState.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketSessionState.java index acb18f801abf..4da7a78cce4b 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketSessionState.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketSessionState.java @@ -23,7 +23,7 @@ import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.core.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; /** * Atomic Connection State diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java index 88a2fff7368d..c6644587257e 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java @@ -22,7 +22,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.server.internal.HandshakerSelector; public interface Handshaker @@ -32,5 +32,5 @@ static Handshaker newInstance() return new HandshakerSelector(); } - boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, FrameHandler.Customizer defaultCustomizer) throws IOException; + boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, Configuration.Customizer defaultCustomizer) throws IOException; } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java index e02a110dc76a..962f28be9de7 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java @@ -23,11 +23,12 @@ import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.util.DecoratedObjectFactory; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; -public interface WebSocketNegotiator extends FrameHandler.Customizer +public interface WebSocketNegotiator extends Configuration.Customizer { FrameHandler negotiate(Negotiation negotiation) throws IOException; @@ -51,7 +52,7 @@ public FrameHandler negotiate(Negotiation negotiation) }; } - static WebSocketNegotiator from(Function negotiate, FrameHandler.Customizer customizer) + static WebSocketNegotiator from(Function negotiate, Configuration.Customizer customizer) { return new AbstractNegotiator(null, customizer) { @@ -66,7 +67,7 @@ public FrameHandler negotiate(Negotiation negotiation) static WebSocketNegotiator from( Function negotiate, WebSocketComponents components, - FrameHandler.Customizer customizer) + Configuration.Customizer customizer) { return new AbstractNegotiator(components, customizer) { @@ -81,21 +82,21 @@ public FrameHandler negotiate(Negotiation negotiation) abstract class AbstractNegotiator implements WebSocketNegotiator { final WebSocketComponents components; - final FrameHandler.Customizer customizer; + final Configuration.Customizer customizer; public AbstractNegotiator() { this(null, null); } - public AbstractNegotiator(WebSocketComponents components, FrameHandler.Customizer customizer) + public AbstractNegotiator(WebSocketComponents components, Configuration.Customizer customizer) { this.components = components == null ? new WebSocketComponents() : components; this.customizer = customizer; } @Override - public void customize(FrameHandler.Configuration configurable) + public void customize(Configuration configurable) { if (customizer != null) customizer.customize(configurable); @@ -125,7 +126,7 @@ public WebSocketComponents getWebSocketComponents() return components; } - public FrameHandler.Customizer getCustomizer() + public Configuration.Customizer getCustomizer() { return customizer; } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java index 61c6b2e3c589..8693dbe35856 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java @@ -38,11 +38,12 @@ import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.websocket.core.Behavior; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.WebSocketConstants; -import org.eclipse.jetty.websocket.core.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.core.internal.ExtensionStack; import org.eclipse.jetty.websocket.core.internal.Negotiated; import org.eclipse.jetty.websocket.core.internal.WebSocketConnection; @@ -57,7 +58,7 @@ public abstract class AbstractHandshaker implements Handshaker private static final HttpField SERVER_VERSION = new PreEncodedHttpField(HttpHeader.SERVER, HttpConfiguration.SERVER_VERSION); @Override - public boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, FrameHandler.Customizer defaultCustomizer) throws IOException + public boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, Configuration.Customizer defaultCustomizer) throws IOException { if (!validateRequest(request)) return false; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java index 9fc542353650..1310298f9b84 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java @@ -22,7 +22,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.server.Handshaker; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; @@ -37,7 +37,7 @@ public class HandshakerSelector implements Handshaker private final RFC8441Handshaker rfc8441 = new RFC8441Handshaker(); @Override - public boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, FrameHandler.Customizer defaultCustomizer) throws IOException + public boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, Configuration.Customizer defaultCustomizer) throws IOException { // Try HTTP/1.1 WS upgrade, if this fails try an HTTP/2 WS upgrade if no response was committed. return rfc6455.upgradeRequest(negotiator, request, response, defaultCustomizer) || diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/AutoFragmentTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/AutoFragmentTest.java index db05b7180b56..1cde7b9a5dd9 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/AutoFragmentTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/AutoFragmentTest.java @@ -74,7 +74,7 @@ public void stop() throws Exception public void testOutgoingAutoFragmentToMaxFrameSize() throws Exception { TestFrameHandler clientHandler = new TestFrameHandler(); - CompletableFuture connect = client.connect(clientHandler, serverUri); + CompletableFuture connect = client.connect(clientHandler, serverUri); connect.get(5, TimeUnit.SECONDS); // Turn off fragmentation on the server. @@ -122,7 +122,7 @@ public void testOutgoingAutoFragmentToMaxFrameSize() throws Exception public void testIncomingAutoFragmentToMaxFrameSize() throws Exception { TestFrameHandler clientHandler = new TestFrameHandler(); - CompletableFuture connect = client.connect(clientHandler, serverUri); + CompletableFuture connect = client.connect(clientHandler, serverUri); connect.get(5, TimeUnit.SECONDS); // Turn off fragmentation on the client. @@ -167,7 +167,7 @@ public void testIncomingAutoFragmentWithPermessageDeflate() throws Exception TestFrameHandler clientHandler = new TestFrameHandler(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, serverUri, clientHandler); upgradeRequest.addExtensions("permessage-deflate"); - CompletableFuture connect = client.connect(upgradeRequest); + CompletableFuture connect = client.connect(upgradeRequest); connect.get(5, TimeUnit.SECONDS); // Turn off fragmentation on the client. @@ -218,7 +218,7 @@ public void testGzipBomb() throws Exception TestFrameHandler clientHandler = new TestFrameHandler(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, serverUri, clientHandler); upgradeRequest.addExtensions("permessage-deflate"); - CompletableFuture connect = client.connect(upgradeRequest); + CompletableFuture connect = client.connect(upgradeRequest); connect.get(5, TimeUnit.SECONDS); // Turn off fragmentation on the client. @@ -282,7 +282,7 @@ public void testOutgoingAutoFragmentWithPermessageDeflate() throws Exception TestFrameHandler clientHandler = new TestFrameHandler(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, serverUri, clientHandler); upgradeRequest.addExtensions("permessage-deflate"); - CompletableFuture connect = client.connect(upgradeRequest); + CompletableFuture connect = client.connect(upgradeRequest); connect.get(5, TimeUnit.SECONDS); // Turn off fragmentation on the client. diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java index 19e440f8dd00..da8ee33408b5 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java @@ -26,7 +26,6 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.websocket.core.FrameHandler.CoreSession; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; import org.junit.jupiter.api.AfterEach; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorFrameFlagsTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorFrameFlagsTest.java index e21ce49fefe9..941101cf3d92 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorFrameFlagsTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorFrameFlagsTest.java @@ -23,6 +23,7 @@ import java.util.stream.Stream; import org.eclipse.jetty.util.BufferUtil; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.internal.ExtensionStack; import org.eclipse.jetty.websocket.core.internal.Generator; import org.eclipse.jetty.websocket.core.internal.Negotiated; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorTest.java index 28d8c8364dda..292f58f041ca 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorTest.java @@ -30,6 +30,8 @@ import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.core.internal.ExtensionStack; import org.eclipse.jetty.websocket.core.internal.Generator; import org.eclipse.jetty.websocket.core.internal.Negotiated; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java index e4e67f8e3ffe..37f811939c6c 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java @@ -29,7 +29,8 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.FutureCallback; -import org.eclipse.jetty.websocket.core.FrameHandler.CoreSession; +import org.eclipse.jetty.websocket.core.exception.BadPayloadException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/OpCodeTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/OpCodeTest.java index c68a4d1eaa27..c7680ffce377 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/OpCodeTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/OpCodeTest.java @@ -18,6 +18,7 @@ package org.eclipse.jetty.websocket.core; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.internal.FrameSequence; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadCloseStatusCodesTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadCloseStatusCodesTest.java index 3dc9212ffa6b..e09c49d95d13 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadCloseStatusCodesTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadCloseStatusCodesTest.java @@ -25,6 +25,7 @@ import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.log.StacklessLogging; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.internal.Parser; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadOpCodesTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadOpCodesTest.java index 48286570d8eb..900b51b33da4 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadOpCodesTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadOpCodesTest.java @@ -25,6 +25,7 @@ import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.log.StacklessLogging; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.internal.Parser; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserReservedBitTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserReservedBitTest.java index 6cd16a093a6e..6613d18d3167 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserReservedBitTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserReservedBitTest.java @@ -25,6 +25,7 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.log.StacklessLogging; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.internal.Generator; import org.eclipse.jetty.websocket.core.internal.Parser; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java index f7dee5b749ba..4486e6901ad1 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java @@ -29,6 +29,8 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.TypeUtil; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.internal.Generator; import org.eclipse.jetty.websocket.core.internal.Parser; import org.hamcrest.Matchers; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java index 53430af39e51..6aa60d090b7b 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java @@ -53,7 +53,7 @@ public FrameHandler negotiate(Negotiation negotiation) throws IOException } @Override - public void customize(FrameHandler.Configuration configurable) + public void customize(Configuration configurable) { } diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java index 63dc1b99b79e..67d41aedd2cf 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java @@ -37,10 +37,10 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.log.StacklessLogging; -import org.eclipse.jetty.websocket.core.FrameHandler.CoreSession; import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.core.client.UpgradeListener; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; +import org.eclipse.jetty.websocket.core.exception.UpgradeException; import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession; import org.eclipse.jetty.websocket.core.server.Negotiation; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketOpenTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketOpenTest.java index a55d389c2c9f..d70097df1a1c 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketOpenTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketOpenTest.java @@ -59,7 +59,7 @@ public void after() throws Exception server.stop(); } - public void setup(BiFunction onOpen) throws Exception + public void setup(BiFunction onOpen) throws Exception { serverHandler = new DemandingAsyncFrameHandler(onOpen); server = new WebSocketServer(serverHandler); @@ -136,7 +136,7 @@ public void testCloseInOnOpen() throws Exception @Test public void testAsyncOnOpen() throws Exception { - Exchanger sx = new Exchanger<>(); + Exchanger sx = new Exchanger<>(); Exchanger cx = new Exchanger<>(); setup((s, c) -> { @@ -153,7 +153,7 @@ public void testAsyncOnOpen() throws Exception return null; }); - FrameHandler.CoreSession coreSession = sx.exchange(null); + CoreSession coreSession = sx.exchange(null); Callback onOpenCallback = cx.exchange(null); Thread.sleep(100); diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnFrameHandler.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnFrameHandler.java index 3de7b168cd25..e79b726af5a7 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnFrameHandler.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnFrameHandler.java @@ -22,6 +22,7 @@ import java.time.Duration; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.TestMessageHandler; public class AutobahnFrameHandler extends TestMessageHandler diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java index 6503abf72eab..8c793b59e234 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java @@ -29,7 +29,7 @@ import org.eclipse.jetty.util.UrlEncoded; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.TestMessageHandler; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; @@ -154,7 +154,7 @@ public int getCaseCount() throws IOException, InterruptedException { URI wsUri = baseWebsocketUri.resolve("/getCaseCount"); TestMessageHandler onCaseCount = new TestMessageHandler(); - Future response = client.connect(onCaseCount, wsUri); + Future response = client.connect(onCaseCount, wsUri); if (waitForUpgrade(wsUri, response)) { @@ -173,7 +173,7 @@ public void runCaseByNumber(int caseNumber) throws IOException, InterruptedExcep LOG.info("test uri: {}", wsUri); AutobahnFrameHandler echoHandler = new AutobahnFrameHandler(); - Future response = client.connect(echoHandler, wsUri); + Future response = client.connect(echoHandler, wsUri); if (waitForUpgrade(wsUri, response)) { // Wait up to 5 min as some of the tests can take a while @@ -201,14 +201,14 @@ public void updateReports() throws IOException, InterruptedException, ExecutionE { URI wsUri = baseWebsocketUri.resolve("/updateReports?agent=" + UrlEncoded.encodeString(userAgent)); TestMessageHandler onUpdateReports = new TestMessageHandler(); - Future response = client.connect(onUpdateReports, wsUri); + Future response = client.connect(onUpdateReports, wsUri); response.get(5, TimeUnit.SECONDS); assertTrue(onUpdateReports.closeLatch.await(15, TimeUnit.SECONDS)); LOG.info("Reports updated."); LOG.info("Test suite finished!"); } - private boolean waitForUpgrade(URI wsUri, Future response) throws InterruptedException + private boolean waitForUpgrade(URI wsUri, Future response) throws InterruptedException { try { diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java index c12c300b7883..f2b861dbe9b6 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java @@ -34,6 +34,7 @@ import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.CloseStatus; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.MessageHandler; import org.eclipse.jetty.websocket.core.server.Negotiation; 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 36d460f3d06e..b8d35bd8fe46 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 @@ -27,7 +27,7 @@ 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.CoreSession; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.TestFrameHandler; import org.eclipse.jetty.websocket.core.WebSocketServer; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java index 01f8ca30b5e4..a1097aefc46f 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java @@ -33,11 +33,11 @@ import org.eclipse.jetty.websocket.core.Behavior; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler.ConfigurationCustomizer; +import org.eclipse.jetty.websocket.core.Configuration.ConfigurationCustomizer; import org.eclipse.jetty.websocket.core.IncomingFramesCapture; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.OutgoingFramesCapture; -import org.eclipse.jetty.websocket.core.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.TestMessageHandler; import org.eclipse.jetty.websocket.core.internal.ExtensionStack; import org.eclipse.jetty.websocket.core.internal.Negotiated; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java index 498ed794f13d..f4dac1f1d975 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java @@ -28,6 +28,7 @@ import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.FrameHandler; @@ -115,7 +116,7 @@ public void onHandshakeRequest(HttpRequest request) }); // Connect to the server. - CompletableFuture connect = client.connect(upgradeRequest); + CompletableFuture connect = client.connect(upgradeRequest); connect.get(5, TimeUnit.SECONDS); // Make sure the internal parameter was not sent to the server. @@ -168,7 +169,7 @@ public void onHandshakeRequest(HttpRequest request) }); // Connect to the server. - CompletableFuture connect = client.connect(upgradeRequest); + CompletableFuture connect = client.connect(upgradeRequest); connect.get(5, TimeUnit.SECONDS); // Make sure the internal parameter was not sent to the server. @@ -222,7 +223,7 @@ public void onHandshakeResponse(HttpRequest request, HttpResponse response) }); // Connect to the server. - CompletableFuture connect = client.connect(upgradeRequest); + CompletableFuture connect = client.connect(upgradeRequest); connect.get(5, TimeUnit.SECONDS); // Make sure the internal parameter was not sent from the server. @@ -276,7 +277,7 @@ public void onHandshakeResponse(HttpRequest request, HttpResponse response) }); // Connect to the server. - CompletableFuture connect = client.connect(upgradeRequest); + CompletableFuture connect = client.connect(upgradeRequest); connect.get(5, TimeUnit.SECONDS); // Make sure the internal parameter was not sent from the server. diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/internal/FrameFlusherTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/internal/FrameFlusherTest.java index 25fb27171b12..6fa6295e7b90 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/internal/FrameFlusherTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/internal/FrameFlusherTest.java @@ -43,7 +43,7 @@ import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.WebSocketConstants; -import org.eclipse.jetty.websocket.core.WebSocketWriteTimeoutException; +import org.eclipse.jetty.websocket.core.exception.WebSocketWriteTimeoutException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxy.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxy.java index 24dd71c2f30a..5f5151e4bd6a 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxy.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxy.java @@ -29,6 +29,7 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.CloseStatus; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.OpCode; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java index b7e3d984dc7f..cad6048e9627 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java @@ -39,10 +39,10 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.log.StacklessLogging; import org.eclipse.jetty.websocket.core.CloseStatus; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.EchoFrameHandler; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.FrameHandler.CoreSession; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.TestAsyncFrameHandler; import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; @@ -72,7 +72,7 @@ public class WebSocketProxyTest private WebSocketProxy proxy; private EchoFrameHandler serverFrameHandler; private TestHandler testHandler; - FrameHandler.ConfigurationCustomizer defaultCustomizer; + Configuration.ConfigurationCustomizer defaultCustomizer; private class TestHandler extends AbstractHandler { @@ -109,7 +109,7 @@ public void start() throws Exception testHandler = new TestHandler(); handlers.addHandler(testHandler); - defaultCustomizer = new FrameHandler.ConfigurationCustomizer(); + defaultCustomizer = new Configuration.ConfigurationCustomizer(); defaultCustomizer.setIdleTimeout(Duration.ofSeconds(3)); ContextHandler serverContext = new ContextHandler("/server"); diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/server/WebSocketServerTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/server/WebSocketServerTest.java index 60ddf4b3a7d8..c1aeb0d8c0fe 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/server/WebSocketServerTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/server/WebSocketServerTest.java @@ -30,6 +30,7 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.CloseStatus; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.RawFrameBuilder; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/InvalidWebSocketException.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/InvalidWebSocketException.java index 04f9457da4eb..7abbc21fdbb6 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/InvalidWebSocketException.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/InvalidWebSocketException.java @@ -18,7 +18,7 @@ package org.eclipse.jetty.websocket.javax.common; -import org.eclipse.jetty.websocket.core.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; /** * Indicating that the provided Class is not a valid WebSocket per the chosen API. diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketAsyncRemote.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketAsyncRemote.java index 5a969df1b520..c8a9fdd8dd07 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketAsyncRemote.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketAsyncRemote.java @@ -30,8 +30,8 @@ import org.eclipse.jetty.util.FutureCallback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.CoreSession; 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.javax.common.messages.MessageOutputStream; import org.eclipse.jetty.websocket.javax.common.messages.MessageWriter; @@ -41,7 +41,7 @@ public class JavaxWebSocketAsyncRemote extends JavaxWebSocketRemoteEndpoint impl { static final Logger LOG = Log.getLogger(JavaxWebSocketAsyncRemote.class); - protected JavaxWebSocketAsyncRemote(JavaxWebSocketSession session, FrameHandler.CoreSession coreSession) + protected JavaxWebSocketAsyncRemote(JavaxWebSocketSession session, CoreSession coreSession) { super(session, coreSession); } diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketBasicRemote.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketBasicRemote.java index facff8479780..80a0c86fac7a 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketBasicRemote.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketBasicRemote.java @@ -29,8 +29,8 @@ import org.eclipse.jetty.util.SharedBlockingCallback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.CoreSession; 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.javax.common.util.TextUtil; @@ -40,7 +40,7 @@ public class JavaxWebSocketBasicRemote extends JavaxWebSocketRemoteEndpoint impl { private static final Logger LOG = Log.getLogger(JavaxWebSocketBasicRemote.class); - protected JavaxWebSocketBasicRemote(JavaxWebSocketSession session, FrameHandler.CoreSession coreSession) + protected JavaxWebSocketBasicRemote(JavaxWebSocketSession session, CoreSession coreSession) { super(session, coreSession); } diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketContainer.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketContainer.java index 6822525f0b54..5ce80190aba9 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketContainer.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketContainer.java @@ -33,7 +33,7 @@ import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; @@ -42,7 +42,7 @@ public abstract class JavaxWebSocketContainer extends ContainerLifeCycle impleme private static final Logger LOG = Log.getLogger(JavaxWebSocketContainer.class); private final SessionTracker sessionTracker = new SessionTracker(); private List sessionListeners = new ArrayList<>(); - protected FrameHandler.ConfigurationCustomizer defaultCustomizer = new FrameHandler.ConfigurationCustomizer(); + protected Configuration.ConfigurationCustomizer defaultCustomizer = new Configuration.ConfigurationCustomizer(); protected WebSocketComponents components; public JavaxWebSocketContainer(WebSocketComponents components) diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java index 378ef535da69..7bd8b0070828 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java @@ -41,11 +41,12 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.CloseStatus; +import org.eclipse.jetty.websocket.core.CoreSession; 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.ProtocolException; -import org.eclipse.jetty.websocket.core.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.javax.common.decoders.AvailableDecoders; import org.eclipse.jetty.websocket.javax.common.messages.DecodedBinaryMessageSink; import org.eclipse.jetty.websocket.javax.common.messages.DecodedBinaryStreamMessageSink; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketRemoteEndpoint.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketRemoteEndpoint.java index d02b27459fa7..df80fbdf880b 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketRemoteEndpoint.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketRemoteEndpoint.java @@ -30,11 +30,11 @@ import org.eclipse.jetty.util.SharedBlockingCallback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.CoreSession; 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.OutgoingFrames; -import org.eclipse.jetty.websocket.core.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.javax.common.messages.MessageOutputStream; import org.eclipse.jetty.websocket.javax.common.messages.MessageWriter; @@ -43,11 +43,11 @@ public class JavaxWebSocketRemoteEndpoint implements javax.websocket.RemoteEndpo private static final Logger LOG = Log.getLogger(JavaxWebSocketRemoteEndpoint.class); protected final JavaxWebSocketSession session; - private final FrameHandler.CoreSession coreSession; + private final CoreSession coreSession; protected boolean batch = false; protected byte messageType = -1; - protected JavaxWebSocketRemoteEndpoint(JavaxWebSocketSession session, FrameHandler.CoreSession coreSession) + protected JavaxWebSocketRemoteEndpoint(JavaxWebSocketSession session, CoreSession coreSession) { this.session = session; this.coreSession = coreSession; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketSession.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketSession.java index 0ba2dee7304a..938aece57534 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketSession.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketSession.java @@ -41,8 +41,8 @@ import org.eclipse.jetty.util.SharedBlockingCallback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.ExtensionConfig; -import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.javax.common.decoders.AvailableDecoders; import org.eclipse.jetty.websocket.javax.common.encoders.AvailableEncoders; import org.eclipse.jetty.websocket.javax.common.util.ReflectUtils; @@ -56,7 +56,7 @@ public class JavaxWebSocketSession implements javax.websocket.Session protected final SharedBlockingCallback blocking = new SharedBlockingCallback(); private final JavaxWebSocketContainer container; - private final FrameHandler.CoreSession coreSession; + private final CoreSession coreSession; private final JavaxWebSocketFrameHandler frameHandler; private final EndpointConfig config; private final AvailableDecoders availableDecoders; @@ -69,7 +69,7 @@ public class JavaxWebSocketSession implements javax.websocket.Session private JavaxWebSocketBasicRemote basicRemote; public JavaxWebSocketSession(JavaxWebSocketContainer container, - FrameHandler.CoreSession coreSession, + CoreSession coreSession, JavaxWebSocketFrameHandler frameHandler, EndpointConfig endpointConfig) { @@ -94,7 +94,7 @@ public JavaxWebSocketSession(JavaxWebSocketContainer container, this.userProperties = this.config.getUserProperties(); } - public FrameHandler.CoreSession getCoreSession() + public CoreSession getCoreSession() { return coreSession; } diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/ByteArrayMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/ByteArrayMessageSink.java index 2d9100ab3af9..0e9f67924998 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/ByteArrayMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/ByteArrayMessageSink.java @@ -27,7 +27,7 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketSession; import org.eclipse.jetty.websocket.javax.common.util.InvalidSignatureException; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/ByteBufferMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/ByteBufferMessageSink.java index ed939a05540b..532ad76b2f79 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/ByteBufferMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/ByteBufferMessageSink.java @@ -25,7 +25,7 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketSession; public class ByteBufferMessageSink extends AbstractMessageSink diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryMessageSink.java index de56031549ac..be4744adfe34 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryMessageSink.java @@ -26,7 +26,7 @@ import javax.websocket.DecodeException; import javax.websocket.Decoder; -import org.eclipse.jetty.websocket.core.CloseException; +import org.eclipse.jetty.websocket.core.exception.CloseException; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketSession; import org.eclipse.jetty.websocket.javax.common.MessageSink; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryStreamMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryStreamMessageSink.java index 4b8d8382639e..916b67711ded 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryStreamMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryStreamMessageSink.java @@ -26,7 +26,7 @@ import javax.websocket.DecodeException; import javax.websocket.Decoder; -import org.eclipse.jetty.websocket.core.CloseException; +import org.eclipse.jetty.websocket.core.exception.CloseException; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketSession; import org.eclipse.jetty.websocket.javax.common.MessageSink; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextMessageSink.java index 07c6c6f99a32..d5db51ec574f 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextMessageSink.java @@ -25,7 +25,7 @@ import javax.websocket.DecodeException; import javax.websocket.Decoder; -import org.eclipse.jetty.websocket.core.CloseException; +import org.eclipse.jetty.websocket.core.exception.CloseException; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketSession; import org.eclipse.jetty.websocket.javax.common.MessageSink; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextStreamMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextStreamMessageSink.java index 7051f38a7d27..439efd0207b7 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextStreamMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextStreamMessageSink.java @@ -26,7 +26,7 @@ import javax.websocket.DecodeException; import javax.websocket.Decoder; -import org.eclipse.jetty.websocket.core.CloseException; +import org.eclipse.jetty.websocket.core.exception.CloseException; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketSession; import org.eclipse.jetty.websocket.javax.common.MessageSink; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageOutputStream.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageOutputStream.java index 0e868f158ed2..8bf5030bbc6a 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageOutputStream.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageOutputStream.java @@ -28,8 +28,8 @@ import org.eclipse.jetty.util.SharedBlockingCallback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.OpCode; /** @@ -39,7 +39,7 @@ public class MessageOutputStream extends OutputStream { private static final Logger LOG = Log.getLogger(MessageOutputStream.class); - private final FrameHandler.CoreSession coreSession; + private final CoreSession coreSession; private final ByteBufferPool bufferPool; private final SharedBlockingCallback blocker; private long frameCount; @@ -49,7 +49,7 @@ public class MessageOutputStream extends OutputStream private Callback callback; private boolean closed; - public MessageOutputStream(FrameHandler.CoreSession coreSession, int bufferSize, ByteBufferPool bufferPool) + public MessageOutputStream(CoreSession coreSession, int bufferSize, ByteBufferPool bufferPool) { this.coreSession = coreSession; this.bufferPool = bufferPool; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriter.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriter.java index 33916a756c70..a9ba0f6f0611 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriter.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriter.java @@ -30,8 +30,8 @@ import org.eclipse.jetty.util.SharedBlockingCallback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.OpCode; import static java.nio.charset.StandardCharsets.UTF_8; @@ -49,7 +49,7 @@ public class MessageWriter extends Writer .onUnmappableCharacter(CodingErrorAction.REPORT) .onMalformedInput(CodingErrorAction.REPORT); - private final FrameHandler.CoreSession coreSession; + private final CoreSession coreSession; private final SharedBlockingCallback blocker; private long frameCount; private Frame frame; @@ -57,7 +57,7 @@ public class MessageWriter extends Writer private Callback callback; private boolean closed; - public MessageWriter(FrameHandler.CoreSession coreSession, int bufferSize) + public MessageWriter(CoreSession coreSession, int bufferSize) { this.coreSession = coreSession; this.blocker = new SharedBlockingCallback(); diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/StringMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/StringMessageSink.java index 291c6a5c67db..7bbf4ad0d913 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/StringMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/StringMessageSink.java @@ -27,7 +27,7 @@ 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.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketSession; public class StringMessageSink extends AbstractMessageSink diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractJavaxWebSocketFrameHandlerTest.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractJavaxWebSocketFrameHandlerTest.java index 412919c77d7c..65395d89792a 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractJavaxWebSocketFrameHandlerTest.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractJavaxWebSocketFrameHandlerTest.java @@ -23,7 +23,7 @@ import javax.websocket.ClientEndpointConfig; import javax.websocket.EndpointConfig; -import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.javax.common.decoders.AvailableDecoders; import org.eclipse.jetty.websocket.javax.common.encoders.AvailableEncoders; import org.junit.jupiter.api.AfterAll; @@ -50,7 +50,7 @@ public static void stopContainer() throws Exception protected AvailableDecoders decoders; protected Map uriParams; protected EndpointConfig endpointConfig; - protected FrameHandler.CoreSession coreSession = new FrameHandler.CoreSession.Empty(); + protected CoreSession coreSession = new CoreSession.Empty(); public AbstractJavaxWebSocketFrameHandlerTest() { diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractSessionTest.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractSessionTest.java index 9411bb26ab20..fc103c406469 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractSessionTest.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/AbstractSessionTest.java @@ -22,7 +22,7 @@ import javax.websocket.EndpointConfig; import javax.websocket.Session; -import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.CoreSession; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -39,7 +39,7 @@ public static void initSession() throws Exception Object websocketPojo = new DummyEndpoint(); UpgradeRequest upgradeRequest = new UpgradeRequestAdapter(); JavaxWebSocketFrameHandler frameHandler = container.newFrameHandler(websocketPojo, upgradeRequest); - FrameHandler.CoreSession coreSession = new FrameHandler.CoreSession.Empty(); + CoreSession coreSession = new CoreSession.Empty(); session = new JavaxWebSocketSession(container, coreSession, frameHandler, container.getFrameHandlerFactory() .newDefaultEndpointConfig(websocketPojo.getClass(), null)); } diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriterTest.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriterTest.java index 24efba23ce22..fa4660c20846 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriterTest.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriterTest.java @@ -26,8 +26,8 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Utf8StringBuilder; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.OpCode; import org.junit.jupiter.api.Test; @@ -139,7 +139,7 @@ public void testSlightLargerThenBufferSize() throws IOException, InterruptedExce assertThat("Message[0].length", message.length(), is(testSize)); } - public static class FrameCapture extends FrameHandler.CoreSession.Empty + public static class FrameCapture extends CoreSession.Empty { public BlockingQueue frames = new LinkedBlockingQueue<>(); @@ -151,7 +151,7 @@ public void sendFrame(Frame frame, Callback callback, boolean batch) } } - public static class WholeMessageCapture extends FrameHandler.CoreSession.Empty + public static class WholeMessageCapture extends CoreSession.Empty { public BlockingQueue messages = new LinkedBlockingQueue<>(); diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java index a20eadd32a30..bfad5ae60aac 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java @@ -37,7 +37,7 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; import org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainer; import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer; diff --git a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java index 274fc1d8c264..dea69e7c8773 100644 --- a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java +++ b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java @@ -31,6 +31,7 @@ import org.eclipse.jetty.util.DecoratedObjectFactory; import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.thread.QueuedThreadPool; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; @@ -116,7 +117,7 @@ public BaseNegotiator() } @Override - public void customize(FrameHandler.Configuration configurable) + public void customize(Configuration configurable) { } @@ -178,7 +179,7 @@ public FrameHandler negotiate(Negotiation negotiation) throws IOException } @Override - public void customize(FrameHandler.Configuration configurable) + public void customize(Configuration configurable) { } } diff --git a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java index 4a9b7a14db1d..ac46308ed2db 100644 --- a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java +++ b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java @@ -36,6 +36,7 @@ import org.eclipse.jetty.util.SharedBlockingCallback; import org.eclipse.jetty.websocket.core.Behavior; import org.eclipse.jetty.websocket.core.CloseStatus; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; @@ -81,7 +82,7 @@ public NetworkFuzzer(LocalServer server, URI wsURI, Map requestH this.client.start(); this.generator = new UnitGenerator(Behavior.CLIENT); - CompletableFuture futureHandler = this.client.connect(upgradeRequest); + CompletableFuture futureHandler = this.client.connect(upgradeRequest); CompletableFuture futureCapture = futureHandler.thenCombine(upgradeRequest.getFuture(), (session, capture) -> capture); this.frameCapture = futureCapture.get(10, TimeUnit.SECONDS); } diff --git a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameEcho.java b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameEcho.java index 6d7cbe87a3d6..5a2fd118f8f7 100644 --- a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameEcho.java +++ b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameEcho.java @@ -22,6 +22,7 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.CloseStatus; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.FrameHandler; diff --git a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameHandlerTracker.java b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameHandlerTracker.java index b4ff93b0a6b9..2a296734d50f 100644 --- a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameHandlerTracker.java +++ b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameHandlerTracker.java @@ -27,6 +27,7 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.CloseStatus; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.MessageHandler; public class FrameHandlerTracker extends MessageHandler diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/com/acme/websocket/IdleTimeoutOnOpenSocket.java b/jetty-websocket/websocket-javax-tests/src/test/java/com/acme/websocket/IdleTimeoutOnOpenSocket.java index 3278e6594dbd..56ff4fc200f7 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/com/acme/websocket/IdleTimeoutOnOpenSocket.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/com/acme/websocket/IdleTimeoutOnOpenSocket.java @@ -24,7 +24,7 @@ import javax.websocket.Session; import javax.websocket.server.ServerEndpoint; -import org.eclipse.jetty.websocket.core.WebSocketTimeoutException; +import org.eclipse.jetty.websocket.core.exception.WebSocketTimeoutException; @ServerEndpoint(value = "/idle-onopen-socket") public class IdleTimeoutOnOpenSocket diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/AbstractClientSessionTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/AbstractClientSessionTest.java index bb59615edc5c..76499f264de2 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/AbstractClientSessionTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/AbstractClientSessionTest.java @@ -18,7 +18,7 @@ package org.eclipse.jetty.websocket.javax.tests.client; -import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.javax.client.BasicClientEndpointConfig; import org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainer; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer; @@ -43,7 +43,7 @@ public static void initSession() throws Exception Object websocketPojo = new DummyEndpoint(); UpgradeRequest upgradeRequest = new UpgradeRequestAdapter(); JavaxWebSocketFrameHandler frameHandler = container.newFrameHandler(websocketPojo, upgradeRequest); - FrameHandler.CoreSession coreSession = new FrameHandler.CoreSession.Empty(); + CoreSession coreSession = new CoreSession.Empty(); session = new JavaxWebSocketSession(container, coreSession, frameHandler, new BasicClientEndpointConfig()); } diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/MessageReceivingTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/MessageReceivingTest.java index 8dd935eaba9d..b5331a36ebc8 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/MessageReceivingTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/MessageReceivingTest.java @@ -41,6 +41,7 @@ import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.MessageHandler; @@ -379,7 +380,7 @@ public FrameHandler negotiate(Negotiation negotiation) throws IOException } @Override - public void customize(FrameHandler.Configuration configurable) + public void customize(Configuration configurable) { configurable.setMaxBinaryMessageSize(MAX_MESSAGE_SIZE); configurable.setMaxTextMessageSize(MAX_MESSAGE_SIZE); diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/OnCloseTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/OnCloseTest.java index 2b6649f413fa..ec2669828c43 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/OnCloseTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/OnCloseTest.java @@ -26,7 +26,7 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.CloseStatus; -import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.javax.client.BasicClientEndpointConfig; import org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainer; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandler; @@ -104,7 +104,7 @@ public void testOnCloseCall(Case testcase) throws Exception UpgradeRequest request = new UpgradeRequestAdapter(); JavaxWebSocketFrameHandler frameHandler = container.newFrameHandler(endpoint, request); - frameHandler.onOpen(new FrameHandler.CoreSession.Empty(), Callback.NOOP); + frameHandler.onOpen(new CoreSession.Empty(), Callback.NOOP); // Execute onClose call frameHandler.onFrame(CloseStatus.toFrame(CloseStatus.NORMAL), Callback.NOOP); diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/SessionAddMessageHandlerTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/SessionAddMessageHandlerTest.java index 94c6eeb68f94..d074a7dd9658 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/SessionAddMessageHandlerTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/SessionAddMessageHandlerTest.java @@ -27,8 +27,8 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.websocket.core.CoreSession; 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.javax.client.BasicClientEndpointConfig; import org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainer; @@ -78,7 +78,7 @@ public void initSession() throws Exception JavaxWebSocketFrameHandlerFactory frameHandlerFactory = new JavaxWebSocketClientFrameHandlerFactory(container); frameHandler = frameHandlerFactory.newJavaxWebSocketFrameHandler(ei, handshakeRequest); - frameHandler.onOpen(new FrameHandler.CoreSession.Empty(), Callback.NOOP); + frameHandler.onOpen(new CoreSession.Empty(), Callback.NOOP); // Session session = frameHandler.getSession(); diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/WriteTimeoutTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/WriteTimeoutTest.java index 160791b315c8..8c22d63b328f 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/WriteTimeoutTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/WriteTimeoutTest.java @@ -30,7 +30,7 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.websocket.core.WebSocketWriteTimeoutException; +import org.eclipse.jetty.websocket.core.exception.WebSocketWriteTimeoutException; import org.eclipse.jetty.websocket.javax.tests.LocalServer; import org.eclipse.jetty.websocket.javax.tests.WSEndpointTracker; import org.hamcrest.Matchers; diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/ConfiguratorTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/ConfiguratorTest.java index ac72ce9732e2..095eaabdac76 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/ConfiguratorTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/ConfiguratorTest.java @@ -53,8 +53,8 @@ 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.CoreSession; 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; @@ -432,9 +432,9 @@ public void testEmptyConfigurator() throws Exception FrameHandlerTracker clientSocket = new FrameHandlerTracker(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.addExtensions("identity"); - Future clientConnectFuture = client.connect(upgradeRequest); + Future clientConnectFuture = client.connect(upgradeRequest); - FrameHandler.CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); + CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); try { coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload(HttpHeader.SEC_WEBSOCKET_EXTENSIONS.asString()), Callback.NOOP, false); @@ -456,9 +456,9 @@ public void testNoExtensionsConfigurator() throws Exception FrameHandlerTracker clientSocket = new FrameHandlerTracker(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.addExtensions("identity"); - Future clientConnectFuture = client.connect(upgradeRequest); + Future clientConnectFuture = client.connect(upgradeRequest); - FrameHandler.CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); + CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); try { coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload("NegoExts"), Callback.NOOP, false); @@ -480,9 +480,9 @@ public void testCaptureRequestHeadersConfigurator() throws Exception FrameHandlerTracker clientSocket = new FrameHandlerTracker(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.header("X-Dummy", "Bogus"); - Future clientConnectFuture = client.connect(upgradeRequest); + Future clientConnectFuture = client.connect(upgradeRequest); - FrameHandler.CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); + CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); try { coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload("X-Dummy"), Callback.NOOP, false); @@ -504,9 +504,9 @@ public void testUniqueUserPropsConfigurator() throws Exception // First Request FrameHandlerTracker clientSocket = new FrameHandlerTracker(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); - Future clientConnectFuture = client.connect(upgradeRequest); + Future clientConnectFuture = client.connect(upgradeRequest); - FrameHandler.CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); + CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); try { // first request has this UserProperty @@ -551,9 +551,9 @@ public void testUserPropsAddress() throws Exception FrameHandlerTracker clientSocket = new FrameHandlerTracker(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); - Future clientConnectFuture = client.connect(upgradeRequest); + Future clientConnectFuture = client.connect(upgradeRequest); - FrameHandler.CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); + CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); try { SocketAddress expectedLocal = coreSession.getLocalAddress(); @@ -593,7 +593,7 @@ public void testProtocol_Single() throws Exception FrameHandlerTracker clientSocket = new FrameHandlerTracker(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.setSubProtocols("status"); - Future clientConnectFuture = client.connect(upgradeRequest); + Future clientConnectFuture = client.connect(upgradeRequest); assertProtocols(clientSocket, clientConnectFuture, is("Requested Protocols: [status]")); } @@ -612,7 +612,7 @@ public void testProtocol_Triple() throws Exception FrameHandlerTracker clientSocket = new FrameHandlerTracker(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.setSubProtocols("echo", "chat", "status"); - Future clientConnectFuture = client.connect(upgradeRequest); + Future clientConnectFuture = client.connect(upgradeRequest); assertProtocols(clientSocket, clientConnectFuture, is("Requested Protocols: [echo,chat,status]")); } @@ -631,7 +631,7 @@ public void testProtocol_LowercaseHeader() throws Exception FrameHandlerTracker clientSocket = new FrameHandlerTracker(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.setSubProtocols("echo", "chat", "status"); - Future clientConnectFuture = client.connect(upgradeRequest); + Future clientConnectFuture = client.connect(upgradeRequest); assertProtocols(clientSocket, clientConnectFuture, is("Requested Protocols: [echo,chat,status]")); } @@ -650,15 +650,15 @@ public void testProtocol_AltHeaderCase() throws Exception FrameHandlerTracker clientSocket = new FrameHandlerTracker(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.setSubProtocols("echo", "chat", "status"); - Future clientConnectFuture = client.connect(upgradeRequest); + Future clientConnectFuture = client.connect(upgradeRequest); assertProtocols(clientSocket, clientConnectFuture, is("Requested Protocols: [echo,chat,status]")); } - protected void assertProtocols(FrameHandlerTracker clientSocket, Future clientConnectFuture, Matcher responseMatcher) + protected void assertProtocols(FrameHandlerTracker clientSocket, Future clientConnectFuture, Matcher responseMatcher) throws InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException { - FrameHandler.CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); + CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); try { coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload("getProtocols"), Callback.NOOP, false); @@ -683,9 +683,9 @@ public void testDecoderWithProtocol() throws Exception FrameHandlerTracker clientSocket = new FrameHandlerTracker(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket); upgradeRequest.setSubProtocols("gmt"); - Future clientConnectFuture = client.connect(upgradeRequest); + Future clientConnectFuture = client.connect(upgradeRequest); - FrameHandler.CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); + CoreSession coreSession = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); try { coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload("2016-06-20T14:27:44"), Callback.NOOP, false); diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/EndpointViaConfigTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/EndpointViaConfigTest.java index 43f0e5dbe8cf..0e1bdffba2cf 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/EndpointViaConfigTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/EndpointViaConfigTest.java @@ -30,8 +30,8 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.websocket.core.CoreSession; 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.WebSocketCoreClient; import org.eclipse.jetty.websocket.javax.tests.WSServer; @@ -76,9 +76,9 @@ public void testEcho() throws Exception { client.start(); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - Future clientConnectFuture = client.connect(clientSocket, uri.resolve("/app/echo")); + Future clientConnectFuture = client.connect(clientSocket, uri.resolve("/app/echo")); // wait for connect - FrameHandler.CoreSession coreSession = clientConnectFuture.get(5, TimeUnit.SECONDS); + CoreSession coreSession = clientConnectFuture.get(5, TimeUnit.SECONDS); try { coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload("Hello World"), Callback.NOOP, false); diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/JavaxWebSocketFrameHandler_OnMessage_TextStreamTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/JavaxWebSocketFrameHandler_OnMessage_TextStreamTest.java index 0891c15d4843..8d9c739eb7fe 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/JavaxWebSocketFrameHandler_OnMessage_TextStreamTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/JavaxWebSocketFrameHandler_OnMessage_TextStreamTest.java @@ -29,8 +29,8 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IO; +import org.eclipse.jetty.websocket.core.CoreSession; 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.javax.common.JavaxWebSocketFrameHandler; import org.eclipse.jetty.websocket.javax.common.UpgradeRequest; @@ -50,7 +50,7 @@ private T performOnMessageInvocation(T socket, Consum // Establish endpoint function JavaxWebSocketFrameHandler frameHandler = container.newFrameHandler(socket, request); - frameHandler.onOpen(new FrameHandler.CoreSession.Empty(), Callback.NOOP); + frameHandler.onOpen(new CoreSession.Empty(), Callback.NOOP); func.accept(frameHandler); return socket; } diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/LargeAnnotatedTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/LargeAnnotatedTest.java index 91a702836d17..e60bcae64fa3 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/LargeAnnotatedTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/LargeAnnotatedTest.java @@ -30,8 +30,8 @@ import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.websocket.core.CoreSession; 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.WebSocketCoreClient; import org.eclipse.jetty.websocket.javax.tests.WSServer; @@ -82,9 +82,9 @@ public void testEcho() throws Exception FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - Future clientConnectFuture = client.connect(clientSocket, uri.resolve("/app/echo/large")); + Future clientConnectFuture = client.connect(clientSocket, uri.resolve("/app/echo/large")); // wait for connect - FrameHandler.CoreSession coreSession = clientConnectFuture.get(1, TimeUnit.SECONDS); + CoreSession coreSession = clientConnectFuture.get(1, TimeUnit.SECONDS); coreSession.setMaxTextMessageSize(128 * 1024); try { diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/LargeContainerTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/LargeContainerTest.java index fbdf26ce9db8..052e451e913b 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/LargeContainerTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/LargeContainerTest.java @@ -29,8 +29,8 @@ import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.websocket.core.CoreSession; 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.WebSocketCoreClient; import org.eclipse.jetty.websocket.javax.tests.WSServer; @@ -71,10 +71,10 @@ public void testEcho() throws Exception client.start(); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - Future clientConnectFuture = client.connect(clientSocket, uri.resolve("/app/echo/large")); + Future clientConnectFuture = client.connect(clientSocket, uri.resolve("/app/echo/large")); // wait for connect - FrameHandler.CoreSession coreSession = clientConnectFuture.get(5, TimeUnit.SECONDS); + CoreSession coreSession = clientConnectFuture.get(5, TimeUnit.SECONDS); coreSession.setMaxTextMessageSize(128 * 1024); try { diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/OnMessageReturnTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/OnMessageReturnTest.java index 1204b55304cb..569bf6838afe 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/OnMessageReturnTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/OnMessageReturnTest.java @@ -32,8 +32,8 @@ import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.websocket.core.CoreSession; 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.WebSocketCoreClient; import org.eclipse.jetty.websocket.javax.tests.WSServer; @@ -105,10 +105,10 @@ public void testEchoReturn() throws Exception client.start(); FrameHandlerTracker clientSocket = new FrameHandlerTracker(); - Future clientConnectFuture = client.connect(clientSocket, uri.resolve("/app/echoreturn")); + Future clientConnectFuture = client.connect(clientSocket, uri.resolve("/app/echoreturn")); // wait for connect - FrameHandler.CoreSession coreSession = clientConnectFuture.get(5, TimeUnit.SECONDS); + CoreSession coreSession = clientConnectFuture.get(5, TimeUnit.SECONDS); try { // Send message diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/PingPongTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/PingPongTest.java index e323ff87ea57..b7edff1a4684 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/PingPongTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/PingPongTest.java @@ -31,8 +31,8 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.websocket.core.CoreSession; 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.WebSocketCoreClient; import org.eclipse.jetty.websocket.javax.tests.Timeouts; @@ -81,14 +81,14 @@ public static void stopServer() throws Exception server.stop(); } - private void assertEcho(String endpointPath, Consumer sendAction, String... expectedMsgs) throws Exception + private void assertEcho(String endpointPath, Consumer sendAction, String... expectedMsgs) throws Exception { FrameHandlerTracker clientSocket = new FrameHandlerTracker(); URI toUri = server.getWsUri().resolve(endpointPath); // Connect - Future futureSession = client.connect(clientSocket, toUri); - FrameHandler.CoreSession coreSession = futureSession.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); + Future futureSession = client.connect(clientSocket, toUri); + CoreSession coreSession = futureSession.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS); try { // Apply send action diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/sockets/IdleTimeoutOnOpenSocket.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/sockets/IdleTimeoutOnOpenSocket.java index 5b9085c3a838..b0802a1e8708 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/sockets/IdleTimeoutOnOpenSocket.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/sockets/IdleTimeoutOnOpenSocket.java @@ -24,7 +24,7 @@ import javax.websocket.Session; import javax.websocket.server.ServerEndpoint; -import org.eclipse.jetty.websocket.core.WebSocketTimeoutException; +import org.eclipse.jetty.websocket.core.exception.WebSocketTimeoutException; @ServerEndpoint(value = "/idle-onopen-socket") public class IdleTimeoutOnOpenSocket diff --git a/jetty-websocket/websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java b/jetty-websocket/websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java index c37ff27ecb9e..bc7f5ffb8598 100644 --- a/jetty-websocket/websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java +++ b/jetty-websocket/websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java @@ -52,7 +52,7 @@ import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandlerFactory; import org.eclipse.jetty.websocket.common.SessionTracker; import org.eclipse.jetty.websocket.common.WebSocketContainer; -import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.client.UpgradeListener; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; @@ -65,7 +65,7 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketPoli private final JettyWebSocketFrameHandlerFactory frameHandlerFactory; private final List sessionListeners = new CopyOnWriteArrayList<>(); private final SessionTracker sessionTracker = new SessionTracker(); - private final FrameHandler.ConfigurationCustomizer configurationCustomizer = new FrameHandler.ConfigurationCustomizer(); + private final Configuration.ConfigurationCustomizer configurationCustomizer = new Configuration.ConfigurationCustomizer(); private final WebSocketComponents components = new WebSocketComponents(); private boolean stopAtShutdown = false; diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/FunctionCallException.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/FunctionCallException.java index 41397859ed9c..855dee065b30 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/FunctionCallException.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/FunctionCallException.java @@ -20,7 +20,7 @@ import java.lang.reflect.InvocationTargetException; -import org.eclipse.jetty.websocket.core.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; public class FunctionCallException extends WebSocketException { diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java index 9a2ccaa23e73..5242d3a81529 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java @@ -31,17 +31,19 @@ import org.eclipse.jetty.websocket.api.UpgradeResponse; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.common.invoke.InvalidSignatureException; -import org.eclipse.jetty.websocket.core.BadPayloadException; -import org.eclipse.jetty.websocket.core.CloseException; +import org.eclipse.jetty.websocket.core.Configuration; +import org.eclipse.jetty.websocket.core.CoreSession; +import org.eclipse.jetty.websocket.core.exception.BadPayloadException; +import org.eclipse.jetty.websocket.core.exception.CloseException; 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.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.core.ProtocolException; -import org.eclipse.jetty.websocket.core.UpgradeException; -import org.eclipse.jetty.websocket.core.WebSocketException; -import org.eclipse.jetty.websocket.core.WebSocketTimeoutException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.UpgradeException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.WebSocketTimeoutException; public class JettyWebSocketFrameHandler implements FrameHandler { @@ -70,7 +72,7 @@ private enum SuspendState private UpgradeRequest upgradeRequest; private UpgradeResponse upgradeResponse; - private final Customizer customizer; + private final Configuration.Customizer customizer; private MessageSink textSink; private MessageSink binarySink; private MessageSink activeMessageSink; @@ -87,7 +89,7 @@ public JettyWebSocketFrameHandler(WebSocketContainer container, MethodHandle frameHandle, MethodHandle pingHandle, MethodHandle pongHandle, BatchMode batchMode, - Customizer customizer) + Configuration.Customizer customizer) { this.log = Log.getLogger(endpointInstance.getClass()); diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerMetadata.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerMetadata.java index a99c2877d7a5..1c4d3f418704 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerMetadata.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerMetadata.java @@ -22,9 +22,9 @@ import org.eclipse.jetty.websocket.api.BatchMode; import org.eclipse.jetty.websocket.api.InvalidWebSocketException; -import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.Configuration; -public class JettyWebSocketFrameHandlerMetadata extends FrameHandler.ConfigurationCustomizer +public class JettyWebSocketFrameHandlerMetadata extends Configuration.ConfigurationCustomizer { private MethodHandle openHandle; private MethodHandle closeHandle; diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java index ca8c3b37fd9c..76e1f69fccd2 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java @@ -28,21 +28,21 @@ import org.eclipse.jetty.util.SharedBlockingCallback; import org.eclipse.jetty.websocket.api.BatchMode; import org.eclipse.jetty.websocket.api.WriteCallback; +import org.eclipse.jetty.websocket.core.CoreSession; 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.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import static java.nio.charset.StandardCharsets.UTF_8; public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket.api.RemoteEndpoint { - private final FrameHandler.CoreSession coreSession; + private final CoreSession coreSession; private byte messageType = -1; private final SharedBlockingCallback blocker = new SharedBlockingCallback(); private BatchMode batchMode; - public JettyWebSocketRemoteEndpoint(FrameHandler.CoreSession coreSession, BatchMode batchMode) + public JettyWebSocketRemoteEndpoint(CoreSession coreSession, BatchMode batchMode) { this.coreSession = Objects.requireNonNull(coreSession); this.batchMode = batchMode; @@ -234,7 +234,7 @@ private void sendBlocking(Frame frame) throws IOException } } - protected FrameHandler.CoreSession getCoreSession() + protected CoreSession getCoreSession() { return coreSession; } diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java index cdbeacf38ea6..eaf3af890a2c 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java @@ -32,18 +32,18 @@ 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.core.FrameHandler; +import org.eclipse.jetty.websocket.core.CoreSession; public class WebSocketSession implements Session, SuspendToken, Dumpable { private static final Logger LOG = Log.getLogger(WebSocketSession.class); - private final FrameHandler.CoreSession coreSession; + private final CoreSession coreSession; private final JettyWebSocketFrameHandler frameHandler; private final JettyWebSocketRemoteEndpoint remoteEndpoint; private final UpgradeRequest upgradeRequest; private final UpgradeResponse upgradeResponse; - public WebSocketSession(FrameHandler.CoreSession coreSession, JettyWebSocketFrameHandler frameHandler) + public WebSocketSession(CoreSession coreSession, JettyWebSocketFrameHandler frameHandler) { this.frameHandler = Objects.requireNonNull(frameHandler); this.coreSession = Objects.requireNonNull(coreSession); @@ -235,7 +235,7 @@ public void resume() frameHandler.resume(); } - public FrameHandler.CoreSession getCoreSession() + public CoreSession getCoreSession() { return coreSession; } diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/ByteArrayMessageSink.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/ByteArrayMessageSink.java index dc5b48a50f74..9cf8d8c91fd8 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/ByteArrayMessageSink.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/ByteArrayMessageSink.java @@ -31,7 +31,7 @@ import org.eclipse.jetty.websocket.common.AbstractMessageSink; import org.eclipse.jetty.websocket.common.invoke.InvalidSignatureException; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; public class ByteArrayMessageSink extends AbstractMessageSink { diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/ByteBufferMessageSink.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/ByteBufferMessageSink.java index d40d7ea1e0ac..5e128c8540d7 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/ByteBufferMessageSink.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/ByteBufferMessageSink.java @@ -31,7 +31,7 @@ import org.eclipse.jetty.websocket.common.AbstractMessageSink; import org.eclipse.jetty.websocket.common.invoke.InvalidSignatureException; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; public class ByteBufferMessageSink extends AbstractMessageSink { diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageOutputStream.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageOutputStream.java index 0275496e9db3..517c8702dbcb 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageOutputStream.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageOutputStream.java @@ -28,8 +28,8 @@ import org.eclipse.jetty.util.SharedBlockingCallback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.OpCode; /** @@ -39,7 +39,7 @@ public class MessageOutputStream extends OutputStream { private static final Logger LOG = Log.getLogger(MessageOutputStream.class); - private final FrameHandler.CoreSession coreSession; + private final CoreSession coreSession; private final ByteBufferPool bufferPool; private final SharedBlockingCallback blocker; private long frameCount; @@ -49,7 +49,7 @@ public class MessageOutputStream extends OutputStream private Callback callback; private boolean closed; - public MessageOutputStream(FrameHandler.CoreSession coreSession, int bufferSize, ByteBufferPool bufferPool) + public MessageOutputStream(CoreSession coreSession, int bufferSize, ByteBufferPool bufferPool) { this.coreSession = coreSession; this.bufferPool = bufferPool; diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java index 534a71940399..fe2d3f5cbf44 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java @@ -30,8 +30,8 @@ import org.eclipse.jetty.util.SharedBlockingCallback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.OpCode; import static java.nio.charset.StandardCharsets.UTF_8; @@ -49,7 +49,7 @@ public class MessageWriter extends Writer .onUnmappableCharacter(CodingErrorAction.REPORT) .onMalformedInput(CodingErrorAction.REPORT); - private final FrameHandler.CoreSession coreSession; + private final CoreSession coreSession; private final SharedBlockingCallback blocker; private long frameCount; private Frame frame; @@ -57,7 +57,7 @@ public class MessageWriter extends Writer private Callback callback; private boolean closed; - public MessageWriter(FrameHandler.CoreSession coreSession, int bufferSize) + public MessageWriter(CoreSession coreSession, int bufferSize) { this.coreSession = coreSession; this.blocker = new SharedBlockingCallback(); diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/StringMessageSink.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/StringMessageSink.java index 8d2780bd5d23..68a246c7e085 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/StringMessageSink.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/message/StringMessageSink.java @@ -33,7 +33,7 @@ import org.eclipse.jetty.websocket.common.AbstractMessageSink; import org.eclipse.jetty.websocket.common.invoke.InvalidSignatureException; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; public class StringMessageSink extends AbstractMessageSink { diff --git a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerTest.java b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerTest.java index 6ac2ec2d3488..e39dbc4f135d 100644 --- a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerTest.java +++ b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerTest.java @@ -38,8 +38,8 @@ import org.eclipse.jetty.websocket.common.endpoints.listeners.ListenerPingPongSocket; import org.eclipse.jetty.websocket.core.Behavior; import org.eclipse.jetty.websocket.core.CloseStatus; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.OpCode; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -67,7 +67,7 @@ public static void stopContainer() throws Exception } private JettyWebSocketFrameHandlerFactory endpointFactory = new JettyWebSocketFrameHandlerFactory(container); - private FrameHandler.CoreSession coreSession = new FrameHandler.CoreSession.Empty() + private CoreSession coreSession = new CoreSession.Empty() { @Override public Behavior getBehavior() diff --git a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java index 76164af72365..c1aee371c84d 100644 --- a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java +++ b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java @@ -40,11 +40,11 @@ import org.eclipse.jetty.websocket.common.message.ByteBufferMessageSink; import org.eclipse.jetty.websocket.common.message.StringMessageSink; import org.eclipse.jetty.websocket.core.CloseStatus; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.OpCode; -public class OutgoingMessageCapture extends FrameHandler.CoreSession.Empty implements FrameHandler.CoreSession +public class OutgoingMessageCapture extends CoreSession.Empty implements CoreSession { private static final Logger LOG = Log.getLogger(OutgoingMessageCapture.class); diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java index f9fa837f8d54..6ce4abe031e7 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java @@ -38,9 +38,9 @@ import org.eclipse.jetty.websocket.api.WebSocketSessionListener; import org.eclipse.jetty.websocket.common.SessionTracker; import org.eclipse.jetty.websocket.common.WebSocketContainer; -import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer; import org.eclipse.jetty.websocket.server.internal.JettyServerFrameHandlerFactory; import org.eclipse.jetty.websocket.servlet.FrameHandlerFactory; @@ -88,7 +88,7 @@ public static JettyWebSocketServerContainer ensureContainer(ServletContext servl private final WebSocketComponents webSocketComponents; private final FrameHandlerFactory frameHandlerFactory; private final Executor executor; - private final FrameHandler.ConfigurationCustomizer customizer = new FrameHandler.ConfigurationCustomizer(); + private final Configuration.ConfigurationCustomizer customizer = new Configuration.ConfigurationCustomizer(); private final List sessionListeners = new ArrayList<>(); private final SessionTracker sessionTracker = new SessionTracker(); diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientConnectTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientConnectTest.java index 2f9988dcaaef..7fefb422b1a0 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientConnectTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientConnectTest.java @@ -427,7 +427,7 @@ public void testConnectionTimeout_Concurrent() throws Exception assertThat(jettyUpgradeException, instanceOf(UpgradeException.class)); Throwable coreUpgradeException = jettyUpgradeException.getCause(); - assertThat(coreUpgradeException, instanceOf(org.eclipse.jetty.websocket.core.UpgradeException.class)); + assertThat(coreUpgradeException, instanceOf(org.eclipse.jetty.websocket.core.exception.UpgradeException.class)); Throwable timeoutException = coreUpgradeException.getCause(); assertThat(timeoutException, instanceOf(TimeoutException.class)); diff --git a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketMapping.java b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketMapping.java index d9233a3b9ce6..e0a54fd153de 100644 --- a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketMapping.java +++ b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketMapping.java @@ -36,9 +36,11 @@ import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.core.Configuration; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.WebSocketException; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.core.server.Handshaker; import org.eclipse.jetty.websocket.core.server.Negotiation; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; @@ -47,13 +49,13 @@ /** * Mapping of pathSpec to a tupple of {@link WebSocketCreator}, {@link FrameHandlerFactory} and - * {@link org.eclipse.jetty.websocket.core.FrameHandler.Customizer}. + * {@link Configuration.Customizer}. *

- * When the {@link #upgrade(HttpServletRequest, HttpServletResponse, FrameHandler.Customizer)} + * When the {@link #upgrade(HttpServletRequest, HttpServletResponse, Configuration.Customizer)} * method is called, a match for the pathSpec is looked for. If one is found then the * creator is used to create a POJO for the WebSocket endpoint, the factory is used to * wrap that POJO with a {@link FrameHandler} and the customizer is used to configure the resulting - * {@link FrameHandler.CoreSession}.

+ * {@link CoreSession}.

*/ public class WebSocketMapping implements Dumpable, LifeCycle.Listener { @@ -187,7 +189,7 @@ public void dump(Appendable out, String indent) throws IOException * @param factory the factory to use to create a FrameHandler for the websocket * @param customizer the customizer to use to customize the WebSocket session. */ - public void addMapping(PathSpec pathSpec, WebSocketCreator creator, FrameHandlerFactory factory, FrameHandler.Customizer customizer) throws WebSocketException + public void addMapping(PathSpec pathSpec, WebSocketCreator creator, FrameHandlerFactory factory, Configuration.Customizer customizer) throws WebSocketException { mappings.put(pathSpec, new Negotiator(creator, factory, customizer)); } @@ -214,7 +216,7 @@ public WebSocketNegotiator getMatchedNegotiator(String target, Consumer Date: Tue, 31 Dec 2019 12:53:05 +1100 Subject: [PATCH 05/12] fix broken test Signed-off-by: Lachlan Roberts --- .../jetty/websocket/core/proxy/WebSocketProxyTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java index cad6048e9627..6f0ad7d209a4 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java @@ -40,9 +40,9 @@ import org.eclipse.jetty.util.log.StacklessLogging; import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.Configuration; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.EchoFrameHandler; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.TestAsyncFrameHandler; import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; @@ -221,7 +221,7 @@ public void testFailServerUpgrade() throws Exception CloseStatus closeStatus = CloseStatus.getCloseStatus(clientFrameHandler.receivedFrames.poll()); assertThat(closeStatus.getCode(), is(CloseStatus.SERVER_ERROR)); - assertThat(closeStatus.getReason(), containsString("Failed to upgrade to websocket: Unexpected HTTP Response Status Code:")); + assertThat(closeStatus.getReason(), containsString("Failed to upgrade to websocket: Unexpected HTTP Response")); } @Test From b14c9b6fae7abd35dbff6c8dce949bd2a6e078dd Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 7 Jan 2020 17:40:11 +0100 Subject: [PATCH 06/12] Updated copyright in new classes. Signed-off-by: Simone Bordet --- .../java/org/eclipse/jetty/websocket/core/Configuration.java | 2 +- .../main/java/org/eclipse/jetty/websocket/core/CoreSession.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java index 09502df70778..0dca1751b1fe 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. // ------------------------------------------------------------------------ // All rights reserved. This program and the accompanying materials // are made available under the terms of the Eclipse Public License v1.0 diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java index 7104323e60a9..6bfe4b015753 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. // ------------------------------------------------------------------------ // All rights reserved. This program and the accompanying materials // are made available under the terms of the Eclipse Public License v1.0 From acabec2e91d5a1004b14c308758629970d34700e Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 22 Jan 2020 16:08:08 +1100 Subject: [PATCH 07/12] fix licence headers and checkstyle Signed-off-by: Lachlan Roberts --- .../jetty/websocket/core/Configuration.java | 24 +++++++++---------- .../jetty/websocket/core/CoreSession.java | 24 +++++++++---------- .../core/client/ClientUpgradeRequest.java | 2 +- .../core/internal/FragmentingFlusher.java | 2 +- .../jetty/websocket/core/internal/Parser.java | 4 ++-- .../internal/PerMessageDeflateExtension.java | 6 ++--- .../core/internal/ValidationExtension.java | 2 +- .../core/internal/WebSocketCoreSession.java | 8 +++---- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java index 0dca1751b1fe..8ca544c15210 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java @@ -1,19 +1,19 @@ // -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// ------------------------------------------------------------------------ -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// and Apache License v2.0 which accompanies this distribution. +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. // -// The Eclipse Public License is available at -// http://www.eclipse.org/legal/epl-v10.html +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 // -// The Apache License v2.0 is available at -// http://www.opensource.org/licenses/apache2.0.php +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 // -// You may elect to redistribute this code under either of these licenses. -// ======================================================================== +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== // package org.eclipse.jetty.websocket.core; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java index 6bfe4b015753..ec946d38dc55 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java @@ -1,19 +1,19 @@ // -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// ------------------------------------------------------------------------ -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// and Apache License v2.0 which accompanies this distribution. +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. // -// The Eclipse Public License is available at -// http://www.eclipse.org/legal/epl-v10.html +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 // -// The Apache License v2.0 is available at -// http://www.opensource.org/licenses/apache2.0.php +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 // -// You may elect to redistribute this code under either of these licenses. -// ======================================================================== +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== // package org.eclipse.jetty.websocket.core; 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 8c57b5c078ab..2ca5886da7f3 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 @@ -54,8 +54,8 @@ import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.exception.UpgradeException; import org.eclipse.jetty.websocket.core.WebSocketConstants; +import org.eclipse.jetty.websocket.core.exception.UpgradeException; import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.core.internal.ExtensionStack; import org.eclipse.jetty.websocket.core.internal.Negotiated; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java index e623389944d2..aa818c950736 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java @@ -23,8 +23,8 @@ 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.Configuration; +import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; /** diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java index 2b7b4e616219..7748273d0c2c 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java @@ -27,11 +27,11 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.CloseStatus; -import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.Configuration.ConfigurationHolder; -import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.exception.WebSocketException; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java index c0643f4131c0..64f961255490 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java @@ -30,13 +30,13 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.AbstractExtension; -import org.eclipse.jetty.websocket.core.exception.BadPayloadException; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.exception.BadPayloadException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; /** * Per Message Deflate Compression extension for WebSocket. diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java index c7ca6628ec78..2ece2f145e4c 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java @@ -27,8 +27,8 @@ import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import static org.eclipse.jetty.websocket.core.OpCode.CONTINUATION; import static org.eclipse.jetty.websocket.core.OpCode.TEXT; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java index 099dd92a2534..3cf6ceeb0baf 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java @@ -36,19 +36,19 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.Behavior; +import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.CoreSession; -import org.eclipse.jetty.websocket.core.exception.CloseException; -import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.IncomingFrames; -import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.OutgoingFrames; -import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.WebSocketConstants; +import org.eclipse.jetty.websocket.core.exception.CloseException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.exception.WebSocketTimeoutException; import org.eclipse.jetty.websocket.core.exception.WebSocketWriteTimeoutException; import org.eclipse.jetty.websocket.core.internal.Parser.ParsedFrame; From f35a01c73cd2f369e29733fd277e1524bdabec16 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 22 Jan 2020 17:26:07 +1100 Subject: [PATCH 08/12] further checkstyle fixes Signed-off-by: Lachlan Roberts --- .../websocket/core/client/WebSocketClientServerTest.java | 2 +- .../core/extensions/PerMessageDeflateExtensionTest.java | 4 ++-- .../server/internal/JavaxWebSocketServerContainer.java | 2 +- .../websocket/common/JettyWebSocketFrameHandler.java | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) 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 2aad46fe91eb..59754fbc0d99 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 @@ -26,8 +26,8 @@ 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.CoreSession; +import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.TestFrameHandler; import org.eclipse.jetty.websocket.core.WebSocketServer; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java index dd2bbbbd5558..aa12bca3d939 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java @@ -31,14 +31,14 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.websocket.core.Behavior; +import org.eclipse.jetty.websocket.core.Configuration.ConfigurationCustomizer; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; -import org.eclipse.jetty.websocket.core.Configuration.ConfigurationCustomizer; import org.eclipse.jetty.websocket.core.IncomingFramesCapture; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.OutgoingFramesCapture; -import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.TestMessageHandler; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.internal.ExtensionStack; import org.eclipse.jetty.websocket.core.internal.Negotiated; import org.eclipse.jetty.websocket.core.internal.PerMessageDeflateExtension; diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java index eeae199b61a2..0c84a4ab83d1 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java @@ -37,8 +37,8 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; +import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainer; import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer; import org.eclipse.jetty.websocket.servlet.WebSocketMapping; diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java index 8a1dc7b850a8..9679928c97da 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java @@ -31,15 +31,15 @@ import org.eclipse.jetty.websocket.api.UpgradeResponse; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.common.invoke.InvalidSignatureException; +import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.CoreSession; -import org.eclipse.jetty.websocket.core.exception.BadPayloadException; -import org.eclipse.jetty.websocket.core.exception.CloseException; -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.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.core.OpCode; +import org.eclipse.jetty.websocket.core.exception.BadPayloadException; +import org.eclipse.jetty.websocket.core.exception.CloseException; +import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.exception.UpgradeException; import org.eclipse.jetty.websocket.core.exception.WebSocketException; From bc88224f1990ce2e106a82ecc40a03e509400b47 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 22 Jan 2020 18:15:59 +1100 Subject: [PATCH 09/12] combine ConfigurationHolder and ConfigurationCustomizer Signed-off-by: Lachlan Roberts --- .../jetty/websocket/core/Configuration.java | 21 ++++++++----------- .../core/internal/FragmentExtension.java | 2 +- .../jetty/websocket/core/internal/Parser.java | 3 +-- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java index 8ca544c15210..208923551f0d 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java @@ -79,16 +79,16 @@ interface Customizer void customize(Configuration configurable); } - class ConfigurationHolder implements Configuration + class ConfigurationCustomizer implements Configuration, Customizer { - protected Duration idleTimeout; - protected Duration writeTimeout; - protected Boolean autoFragment; - protected Long maxFrameSize; - protected Integer outputBufferSize; - protected Integer inputBufferSize; - protected Long maxBinaryMessageSize; - protected Long maxTextMessageSize; + private Duration idleTimeout; + private Duration writeTimeout; + private Boolean autoFragment; + private Long maxFrameSize; + private Integer outputBufferSize; + private Integer inputBufferSize; + private Long maxBinaryMessageSize; + private Long maxTextMessageSize; @Override public Duration getIdleTimeout() @@ -185,10 +185,7 @@ public void setMaxTextMessageSize(long maxTextMessageSize) { this.maxTextMessageSize = maxTextMessageSize; } - } - class ConfigurationCustomizer extends ConfigurationHolder implements Customizer - { @Override public void customize(Configuration configurable) { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java index 6cb3a969e217..6d1cecab62a6 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java @@ -35,7 +35,7 @@ public class FragmentExtension extends AbstractExtension private static final Logger LOG = Log.getLogger(FragmentExtension.class); private final FragmentingFlusher flusher; - private final Configuration configuration = new Configuration.ConfigurationHolder(); + private final Configuration configuration = new Configuration.ConfigurationCustomizer(); public FragmentExtension() { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java index 7748273d0c2c..9ba506a8218a 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java @@ -28,7 +28,6 @@ import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.Configuration; -import org.eclipse.jetty.websocket.core.Configuration.ConfigurationHolder; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; @@ -65,7 +64,7 @@ private enum State public Parser(ByteBufferPool bufferPool) { - this(bufferPool, new ConfigurationHolder()); + this(bufferPool, new Configuration.ConfigurationCustomizer()); } public Parser(ByteBufferPool bufferPool, Configuration configuration) From 64d72abde60a910e9e9cc56daaa30a069bd9cb61 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Thu, 23 Jan 2020 10:20:40 +1100 Subject: [PATCH 10/12] Extension interface now uses CoreSession and not Configuration Signed-off-by: Lachlan Roberts --- .../jetty/websocket/core/AbstractExtension.java | 4 ++-- .../org/eclipse/jetty/websocket/core/Extension.java | 5 +++-- .../jetty/websocket/core/internal/ExtensionStack.java | 2 +- .../websocket/core/internal/ValidationExtension.java | 11 ++++++----- .../websocket/core/extensions/ExtensionTool.java | 2 +- .../extensions/PerMessageDeflateExtensionTest.java | 6 +++--- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java index ca8500453d8a..bb9a9d2e849e 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java @@ -168,9 +168,9 @@ public void setNextOutgoingFrames(OutgoingFrames nextOutgoing) } @Override - public void setConfiguration(Configuration configuration) + public void setCoreSession(CoreSession coreSession) { - this.configuration = configuration; + this.configuration = coreSession; } protected Configuration getConfiguration() diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java index 2fdd345f543a..9e67ffa51c51 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java @@ -86,7 +86,8 @@ public interface Extension extends IncomingFrames, OutgoingFrames void setNextOutgoingFrames(OutgoingFrames nextOutgoing); /** - * Set the {@link Configuration} for this Extension. + * Set the {@link CoreSession} for this Extension. + * @param coreSession */ - void setConfiguration(Configuration configuration); + void setCoreSession(CoreSession coreSession); } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java index 8f661710a2f4..c1e0cc448e98 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java @@ -254,7 +254,7 @@ public void initialize(IncomingFrames incoming, OutgoingFrames outgoing, WebSock for (Extension extension : extensions) { - extension.setConfiguration(coreSession); + extension.setCoreSession(coreSession); } } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java index 2ece2f145e4c..3cc5f0166eec 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java @@ -24,7 +24,7 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.AbstractExtension; -import org.eclipse.jetty.websocket.core.Configuration; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.WebSocketComponents; @@ -55,13 +55,14 @@ public String getName() } @Override - public void setConfiguration(Configuration configuration) + public void setCoreSession(CoreSession coreSession) { - super.setConfiguration(configuration); + super.setCoreSession(coreSession); - if (!(configuration instanceof WebSocketCoreSession)) + // TODO: change validation to use static methods instead of down casting CoreSession. + if (!(coreSession instanceof WebSocketCoreSession)) throw new IllegalArgumentException("ValidationExtension needs a CoreSession Configuration"); - coreSession = (WebSocketCoreSession)configuration; + this.coreSession = (WebSocketCoreSession)coreSession; } @Override diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java index 6b70e2b725c7..c6ee2bf10832 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java @@ -77,7 +77,7 @@ public void assertNegotiated(String expectedNegotiation) { this.ext = components.getExtensionRegistry().newInstance(extConfig, components); this.ext.setNextIncomingFrames(capture); - this.ext.setConfiguration(newWebSocketCoreSession()); + this.ext.setCoreSession(newWebSocketCoreSession()); } public void parseIncomingHex(String... rawhex) diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java index aa12bca3d939..22d881d99961 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java @@ -376,7 +376,7 @@ public void testIncomingFrameNoPayload() PerMessageDeflateExtension ext = new PerMessageDeflateExtension(); ExtensionConfig config = ExtensionConfig.parse("permessage-deflate"); ext.init(config, components); - ext.setConfiguration(newSession()); + ext.setCoreSession(newSession()); // Setup capture of incoming frames IncomingFramesCapture capture = new IncomingFramesCapture(); @@ -450,7 +450,7 @@ public void testOutgoingFragmentedMessage() throws IOException, InterruptedExcep { PerMessageDeflateExtension ext = new PerMessageDeflateExtension(); ext.init(ExtensionConfig.parse("permessage-deflate"), components); - ext.setConfiguration(newSession()); + ext.setCoreSession(newSession()); // Setup capture of outgoing frames OutgoingFramesCapture capture = new OutgoingFramesCapture(); @@ -497,7 +497,7 @@ public void testOutgoingFrameNoPayload() PerMessageDeflateExtension ext = new PerMessageDeflateExtension(); ExtensionConfig config = ExtensionConfig.parse("permessage-deflate"); ext.init(config, components); - ext.setConfiguration(newSession()); + ext.setCoreSession(newSession()); // Setup capture of incoming frames OutgoingFramesCapture capture = new OutgoingFramesCapture(); From 6c2c4d8ad78d6aa78b05135410212f825aeac185 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Fri, 24 Jan 2020 11:05:14 +1100 Subject: [PATCH 11/12] Issue 4450 - remove ConfigurationCustomizer static method Signed-off-by: Lachlan Roberts --- .../org/eclipse/jetty/websocket/core/Configuration.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java index 208923551f0d..ffc2d8d9225c 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java @@ -206,13 +206,5 @@ public void customize(Configuration configurable) if (maxTextMessageSize != null) configurable.setMaxTextMessageSize(maxTextMessageSize); } - - public static ConfigurationCustomizer from(ConfigurationCustomizer parent, ConfigurationCustomizer child) - { - ConfigurationCustomizer customizer = new ConfigurationCustomizer(); - parent.customize(customizer); - child.customize(customizer); - return customizer; - } } } From 96741ebb287bb7572b5a586ca271633797e55539 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 29 Jan 2020 10:11:21 +0100 Subject: [PATCH 12/12] Fixed compilation issues after merge. Signed-off-by: Simone Bordet --- .../jetty/websocket/core/FlushTest.java | 6 +- .../common/JettyWebSocketRemoteEndpoint.java | 8 +-- .../servlet/WebSocketServletFactory.java | 57 +------------------ 3 files changed, 10 insertions(+), 61 deletions(-) diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java index 597ef213d829..f787ae8fd894 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java @@ -67,7 +67,7 @@ public void shutdown() throws Exception public void testStandardFlush() throws Exception { TestFrameHandler clientHandler = new TestFrameHandler(); - CompletableFuture connect = client.connect(clientHandler, server.getUri()); + CompletableFuture connect = client.connect(clientHandler, server.getUri()); connect.get(5, TimeUnit.SECONDS); // Send a batched frame. @@ -94,7 +94,7 @@ public void testStandardFlush() throws Exception public void testFlushOnCloseFrame() throws Exception { TestFrameHandler clientHandler = new TestFrameHandler(); - CompletableFuture connect = client.connect(clientHandler, server.getUri()); + CompletableFuture connect = client.connect(clientHandler, server.getUri()); connect.get(5, TimeUnit.SECONDS); // Send a batched frame. @@ -120,7 +120,7 @@ public void testFlushOnCloseFrame() throws Exception public void testFlushAfterClose() throws Exception { TestFrameHandler clientHandler = new TestFrameHandler(); - CompletableFuture connect = client.connect(clientHandler, server.getUri()); + CompletableFuture connect = client.connect(clientHandler, server.getUri()); connect.get(5, TimeUnit.SECONDS); clientHandler.sendClose(); diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java index 7d66e5448080..4307c3600dea 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java @@ -32,10 +32,10 @@ import org.eclipse.jetty.websocket.api.BatchMode; import org.eclipse.jetty.websocket.api.StatusCode; import org.eclipse.jetty.websocket.api.WriteCallback; +import org.eclipse.jetty.websocket.core.CoreSession; 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.ProtocolException; +import org.eclipse.jetty.websocket.core.exception.ProtocolException; import static java.nio.charset.StandardCharsets.UTF_8; @@ -43,11 +43,11 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket { private static final Logger LOG = Log.getLogger(JettyWebSocketRemoteEndpoint.class); - private final FrameHandler.CoreSession coreSession; + private final CoreSession coreSession; private byte messageType = -1; private BatchMode batchMode; - public JettyWebSocketRemoteEndpoint(FrameHandler.CoreSession coreSession, BatchMode batchMode) + public JettyWebSocketRemoteEndpoint(CoreSession coreSession, BatchMode batchMode) { this.coreSession = Objects.requireNonNull(coreSession); this.batchMode = batchMode; diff --git a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServletFactory.java b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServletFactory.java index d22a80fa6205..f62a25056e5c 100644 --- a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServletFactory.java +++ b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServletFactory.java @@ -18,65 +18,14 @@ package org.eclipse.jetty.websocket.servlet; -import java.time.Duration; - import org.eclipse.jetty.http.pathmap.PathSpec; import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; public interface WebSocketServletFactory extends Configuration { - WebSocketExtensionRegistry getExtensionRegistry(); - @Override - Duration getIdleTimeout(); - - @Override - void setIdleTimeout(Duration duration); - - @Override - Duration getWriteTimeout(); - - @Override - void setWriteTimeout(Duration duration); - - @Override - int getInputBufferSize(); - - @Override - void setInputBufferSize(int bufferSize); - - @Override - long getMaxFrameSize(); - - @Override - void setMaxFrameSize(long maxFrameSize); - - @Override - long getMaxBinaryMessageSize(); - - @Override - void setMaxBinaryMessageSize(long bufferSize); - - @Override - long getMaxTextMessageSize(); - - @Override - void setMaxTextMessageSize(long bufferSize); - - @Override - int getOutputBufferSize(); - - @Override - void setOutputBufferSize(int bufferSize); - - @Override - boolean isAutoFragment(); - - @Override - void setAutoFragment(boolean autoFragment); - void addMapping(String pathSpec, WebSocketCreator creator); /** @@ -129,11 +78,11 @@ public interface WebSocketServletFactory extends Configuration * Recognized Path Spec syntaxes: *

*
- *
/path/to or / or *.ext or servlet|{spec}
+ *
{@code /path/to} or {@code /} or {@code *.ext} or {@code servlet|{spec}}
*
Servlet Syntax
- *
^{spec} or regex|{spec}
+ *
{@code ^{spec}} or {@code regex|{spec}}
*
Regex Syntax
- *
uri-template|{spec}
+ *
{@code uri-template|{spec}}
*
URI Template (see JSR356 and RFC6570 level 1)
*
*