diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml index e427ea542d9..de213dd80fb 100644 --- a/jetty-jndi/pom.xml +++ b/jetty-jndi/pom.xml @@ -25,28 +25,11 @@ org.apache.felix maven-bundle-plugin true - - - javax.mail.*;resolution:=optional,* - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - package - - single - - - - src/main/assembly/config.xml - - - - + + + javax.mail.*;resolution:=optional,* + + org.codehaus.mojo diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml index 3aab5947a6f..8865ba4e568 100644 --- a/jetty-plus/pom.xml +++ b/jetty-plus/pom.xml @@ -1,4 +1,6 @@ - + org.eclipse.jetty jetty-project @@ -36,32 +38,15 @@ org.apache.maven.plugins maven-source-plugin - - org.apache.maven.plugins - maven-assembly-plugin - - - package - - single - - - - src/main/assembly/config.xml - - - - - org.apache.felix maven-bundle-plugin true - - - javax.transaction*;version="[1.1,1.3)",* - - + + + javax.transaction*;version="[1.1,1.3)",* + + org.codehaus.mojo diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java index cbbcef52654..4ad2cbbe6b3 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java @@ -117,8 +117,7 @@ public class ServerContainer extends ClientContainer implements javax.websocket. if (anno != null) { // Overwrite Config from Annotation - // TODO: should we merge with provided config? - return new AnnotatedServerEndpointConfig(this, endpoint.getClass(), anno, config); + return new AnnotatedServerEndpointConfig(this, endpoint.getClass(), anno, (ServerEndpointConfig) config); } return config; } diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java index 22be1136ad2..2efaeeac2c4 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java @@ -182,7 +182,7 @@ public abstract class AbstractExtension extends AbstractLifeCycle implements Dum catch (Throwable t) { if (callback != null) - callback.writeFailed(t); + callback.fail(t); else log.warn(t); } diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/FrameFlusherTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/FrameFlusherTest.java index 283f728a6d0..8e8fc1951ee 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/FrameFlusherTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/FrameFlusherTest.java @@ -20,33 +20,21 @@ package org.eclipse.jetty.websocket.common.io; import static java.nio.charset.StandardCharsets.UTF_8; -import java.io.IOException; -import java.net.InetSocketAddress; import java.nio.ByteBuffer; -import java.nio.channels.ReadPendingException; import java.nio.channels.WritePendingException; import java.util.Arrays; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; import org.eclipse.jetty.io.ByteBufferPool; -import org.eclipse.jetty.io.Connection; -import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.util.FutureCallback; import org.eclipse.jetty.websocket.api.BatchMode; import org.eclipse.jetty.websocket.api.WebSocketPolicy; -import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.api.extensions.Frame; -import org.eclipse.jetty.websocket.api.extensions.IncomingFrames; -import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames; import org.eclipse.jetty.websocket.common.Generator; import org.eclipse.jetty.websocket.common.Parser; -import org.eclipse.jetty.websocket.common.SaneFrameOrderingAssertion; import org.eclipse.jetty.websocket.common.WebSocketFrame; -import org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint; import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.junit.Rule; import org.junit.Test; @@ -112,7 +100,7 @@ public class FrameFlusherTest System.out.printf("Received: %,d frames / %,d errors%n", endPoint.incomingFrames, endPoint.incomingErrors); } - public static class SaneFrameOrderingEndPoint extends MockEndPoint implements IncomingFrames + public static class SaneFrameOrderingEndPoint extends MockEndPoint implements Parser.Handler { public Parser parser; public int incomingFrames; @@ -120,20 +108,13 @@ public class FrameFlusherTest public SaneFrameOrderingEndPoint(WebSocketPolicy policy, ByteBufferPool bufferPool) { - parser = new Parser(policy, bufferPool); - parser.setIncomingFramesHandler(this); + parser = new Parser(policy, bufferPool, this); } @Override - public void incomingError(Throwable t) + public boolean onFrame(Frame frame) { - incomingErrors++; - } - - @Override - public void incomingFrame(Frame frame) - { - incomingFrames++; + return true; } @Override diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/SaneFrameOrderingAssertion.java b/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/SaneFrameOrderingAssertion.java similarity index 91% rename from jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/SaneFrameOrderingAssertion.java rename to jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/SaneFrameOrderingAssertion.java index 2140d234c99..516a02e9291 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/SaneFrameOrderingAssertion.java +++ b/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/SaneFrameOrderingAssertion.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.common; +package org.eclipse.jetty.websocket.tests; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -24,9 +24,11 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.eclipse.jetty.websocket.api.BatchMode; +import org.eclipse.jetty.websocket.api.FrameCallback; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.api.extensions.Frame; import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames; +import org.eclipse.jetty.websocket.common.OpCode; /** * Useful for testing the production of sane frame ordering from various components. @@ -37,7 +39,7 @@ public class SaneFrameOrderingAssertion implements OutgoingFrames public int frameCount = 0; @Override - public void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode) + public void outgoingFrame(Frame frame, FrameCallback callback, BatchMode batchMode) { byte opcode = frame.getOpCode(); assertThat("OpCode.isKnown(" + opcode + ")", OpCode.isKnown(opcode), is(true)); @@ -72,6 +74,6 @@ public class SaneFrameOrderingAssertion implements OutgoingFrames frameCount++; if (callback != null) - callback.writeSuccess(); + callback.succeed(); } } diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/ByteAccumulatorTest.java b/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/extensions/ByteAccumulatorTest.java similarity index 96% rename from jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/ByteAccumulatorTest.java rename to jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/extensions/ByteAccumulatorTest.java index e182eae2844..12dd99af8d5 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/ByteAccumulatorTest.java +++ b/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/extensions/ByteAccumulatorTest.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.common.extensions.compress; +package org.eclipse.jetty.websocket.tests.extensions; import static java.nio.charset.StandardCharsets.UTF_8; import static org.hamcrest.CoreMatchers.containsString; @@ -27,6 +27,7 @@ import java.nio.ByteBuffer; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.api.MessageTooLargeException; +import org.eclipse.jetty.websocket.common.extensions.compress.ByteAccumulator; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; diff --git a/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/extensions/FragmentExtensionTest.java b/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/extensions/FragmentExtensionTest.java index 0518a94b1ea..f6725797a3b 100644 --- a/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/extensions/FragmentExtensionTest.java +++ b/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/extensions/FragmentExtensionTest.java @@ -36,15 +36,14 @@ import org.eclipse.jetty.io.LeakTrackingByteBufferPool; import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.toolchain.test.ByteBufferAssert; import org.eclipse.jetty.util.BufferUtil; -import org.eclipse.jetty.util.log.Log; -import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.api.BatchMode; import org.eclipse.jetty.websocket.api.FrameCallback; import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; import org.eclipse.jetty.websocket.api.extensions.Frame; import org.eclipse.jetty.websocket.common.OpCode; -import org.eclipse.jetty.websocket.common.SaneFrameOrderingAssertion; +import org.eclipse.jetty.websocket.common.io.FutureWriteCallback; +import org.eclipse.jetty.websocket.tests.SaneFrameOrderingAssertion; import org.eclipse.jetty.websocket.common.WebSocketFrame; import org.eclipse.jetty.websocket.common.extensions.fragment.FragmentExtension; import org.eclipse.jetty.websocket.common.frames.ContinuationFrame; diff --git a/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/jsr356/ConfiguratorTest.java b/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/jsr356/ConfiguratorTest.java index 025cd0c911a..16e31d5ea18 100644 --- a/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/jsr356/ConfiguratorTest.java +++ b/jetty-websocket/websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/jsr356/ConfiguratorTest.java @@ -36,6 +36,7 @@ import java.util.Locale; import java.util.Map; import java.util.TimeZone; import java.util.concurrent.Future; +import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -62,6 +63,8 @@ import org.eclipse.jetty.websocket.api.util.QuoteUtil; import org.eclipse.jetty.websocket.api.util.WSURI; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; +import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.jsr356.server.JsrCreator; import org.eclipse.jetty.websocket.jsr356.server.ServerContainer; import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer; @@ -69,6 +72,7 @@ import org.eclipse.jetty.websocket.tests.Defaults; import org.eclipse.jetty.websocket.tests.TrackingEndpoint; import org.junit.After; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; @@ -719,17 +723,19 @@ public class ConfiguratorTest @Test public void testAnnotationConfigurator() throws Exception { - URI uri = baseServerUri.resolve("/config-normal"); - BlockheadClientRequest request = client.newWsRequest(uri); - Future connFut = request.sendAsync(); + URI wsUri = baseServerUri.resolve("/config-normal"); - try (BlockheadConnection clientConn = connFut.get(Timeouts.CONNECT, Timeouts.CONNECT_UNIT)) - { - clientConn.write(new TextFrame().setPayload("tellme")); - LinkedBlockingQueue frames = clientConn.getFrameQueue(); - WebSocketFrame frame = frames.poll(Timeouts.POLL_EVENT, Timeouts.POLL_EVENT_UNIT); - Assert.assertThat("Frame Response", frame.getPayloadAsUTF8(), is("UserProperties[self.configurator] = " + ConfigNormalConfigurator.class.getName())); - } + TrackingEndpoint clientSocket = new TrackingEndpoint(testname.getMethodName()); + ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest(); + + Future clientConnectFuture = client.connect(clientSocket, wsUri, upgradeRequest); + + org.eclipse.jetty.websocket.api.Session clientSession = clientConnectFuture.get(Defaults.CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS); + + clientSession.getRemote().sendString("tellme"); + + String incomingMessage = clientSocket.messageQueue.poll(5, TimeUnit.SECONDS); + assertThat("Incoming message", incomingMessage, is("UserProperties[self.configurator] = " + ConfigNormalConfigurator.class.getName())); } /** @@ -739,16 +745,17 @@ public class ConfiguratorTest @Test public void testOverrideConfigurator() throws Exception { - URI uri = baseServerUri.resolve("/config-override"); - BlockheadClientRequest request = client.newWsRequest(uri); - Future connFut = request.sendAsync(); + URI wsUri = baseServerUri.resolve("/config-override"); + TrackingEndpoint clientSocket = new TrackingEndpoint(testname.getMethodName()); + ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest(); - try (BlockheadConnection clientConn = connFut.get(Timeouts.CONNECT, Timeouts.CONNECT_UNIT)) - { - clientConn.write(new TextFrame().setPayload("tellme")); - LinkedBlockingQueue frames = clientConn.getFrameQueue(); - WebSocketFrame frame = frames.poll(Timeouts.POLL_EVENT, Timeouts.POLL_EVENT_UNIT); - Assert.assertThat("Frame Response", frame.getPayloadAsUTF8(), is("UserProperties[self.configurator] = " + ConfigOverrideConfigurator.class.getName())); - } + Future clientConnectFuture = client.connect(clientSocket, wsUri, upgradeRequest); + + org.eclipse.jetty.websocket.api.Session clientSession = clientConnectFuture.get(Defaults.CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS); + + clientSession.getRemote().sendString("tellme"); + + String incomingMessage = clientSocket.messageQueue.poll(5, TimeUnit.SECONDS); + assertThat("Incoming message", incomingMessage, is("UserProperties[self.configurator] = " + ConfigOverrideConfigurator.class.getName())); } }