From 19e2ab8a70ebcb9592cb9f383efd0722cd025c71 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 9 Jan 2019 14:32:37 +1100 Subject: [PATCH 1/7] Issue #3246 - fix to DecoderReaderManySmallTest stacktrace being logged succeed the callback in EventIdFrameHandler after sending responses in DecoderReaderManySmallTest Signed-off-by: Lachlan Roberts --- .../client/DecoderReaderManySmallTest.java | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/DecoderReaderManySmallTest.java b/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/DecoderReaderManySmallTest.java index 71d97ce28b8..03f41ca1d42 100644 --- a/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/DecoderReaderManySmallTest.java +++ b/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/DecoderReaderManySmallTest.java @@ -18,6 +18,24 @@ package org.eclipse.jetty.websocket.javax.tests.client; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.TimeUnit; +import javax.websocket.ClientEndpoint; +import javax.websocket.ContainerProvider; +import javax.websocket.DecodeException; +import javax.websocket.Decoder; +import javax.websocket.EndpointConfig; +import javax.websocket.OnMessage; +import javax.websocket.Session; +import javax.websocket.WebSocketContainer; + import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.MessageHandler; @@ -29,24 +47,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; -import javax.websocket.ClientEndpoint; -import javax.websocket.ContainerProvider; -import javax.websocket.DecodeException; -import javax.websocket.Decoder; -import javax.websocket.EndpointConfig; -import javax.websocket.OnMessage; -import javax.websocket.Session; -import javax.websocket.WebSocketContainer; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.Reader; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingDeque; -import java.util.concurrent.TimeUnit; - import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -90,12 +90,14 @@ public class DecoderReaderManySmallTest { URI wsUri = server.getWsUri().resolve("/eventids"); EventIdSocket clientSocket = new EventIdSocket(testInfo.getTestMethod().toString()); - Session clientSession = client.connectToServer(clientSocket, wsUri); final int from = 1000; final int to = 2000; - clientSession.getAsyncRemote().sendText("seq|" + from + "|" + to); + try(Session clientSession = client.connectToServer(clientSocket, wsUri)) + { + clientSession.getAsyncRemote().sendText("seq|" + from + "|" + to); + } // collect seen ids List seen = new ArrayList<>(); @@ -181,6 +183,8 @@ public class DecoderReaderManySmallTest sendText(Integer.toString(id), Callback.NOOP, false); } } + + getCoreSession().flush(callback); } } } From c36d9bc3fc1450f2c10fc795b5b86510f8afe851 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 9 Jan 2019 14:37:51 +1100 Subject: [PATCH 2/7] Issue #3246 - suppressed logging for stacktrace in IdleTimeoutTest Signed-off-by: Lachlan Roberts --- .../websocket/javax/tests/server/IdleTimeoutTest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/IdleTimeoutTest.java b/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/IdleTimeoutTest.java index c180d0a715c..2736767e2ed 100644 --- a/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/IdleTimeoutTest.java +++ b/jetty-websocket/javax-websocket-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/IdleTimeoutTest.java @@ -18,7 +18,11 @@ package org.eclipse.jetty.websocket.javax.tests.server; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.TimeUnit; + import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.eclipse.jetty.util.log.StacklessLogging; import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.Frame; @@ -31,9 +35,6 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.TimeUnit; - import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; @@ -69,7 +70,8 @@ public class IdleTimeoutTest private void assertConnectionTimeout(String requestPath) throws Exception { - try (Fuzzer session = server.newNetworkFuzzer(requestPath)) + try (Fuzzer session = server.newNetworkFuzzer(requestPath); + StacklessLogging stacklessLogging = new StacklessLogging(IdleTimeoutOnOpenSocket.class)) { // wait 1 second to allow timeout to fire off TimeUnit.SECONDS.sleep(1); From 40f1d5866fdba904ba5bed2a47e65656c2396819 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 9 Jan 2019 16:19:55 +1100 Subject: [PATCH 3/7] call succeeded() to drain the queue instead of calling failed() in the ExtensionStack Flusher documentation fix in WriteFlusher Signed-off-by: Lachlan Roberts --- .../org/eclipse/jetty/io/WriteFlusher.java | 2 +- .../core/internal/ExtensionStack.java | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java b/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java index e0f1d8c0603..dee91e31471 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java @@ -100,7 +100,7 @@ abstract public class WriteFlusher * @param previous the expected current state * @param next the desired new state * @return the previous state or null if the state transition failed - * @throws WritePendingException if currentState is WRITING and new state is WRITING (api usage error) + * @throws IllegalStateException if previous->next is not a legal state transition (api usage error) */ private boolean updateState(State previous, State next) { 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 c99c938fd42..ee6a0577c2d 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 @@ -18,6 +18,15 @@ package org.eclipse.jetty.websocket.core.internal; +import java.io.IOException; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.ListIterator; +import java.util.Queue; +import java.util.stream.Collectors; + import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.DecoratedObjectFactory; @@ -34,15 +43,6 @@ import org.eclipse.jetty.websocket.core.IncomingFrames; import org.eclipse.jetty.websocket.core.OutgoingFrames; import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; -import java.io.IOException; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.ListIterator; -import java.util.Queue; -import java.util.stream.Collectors; - /** * Represents the stack of Extensions. */ @@ -353,7 +353,7 @@ public class ExtensionStack implements IncomingFrames, OutgoingFrames, Dumpable // and the failure of a frame may not mean that the whole // connection is now invalid. notifyCallbackFailure(current.callback, cause); - super.failed(cause); + super.succeeded(); } private void notifyCallbackSuccess(Callback callback) From 9f3f3b78aec8ea8f9b296d598e79a674e28a0f52 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Tue, 15 Jan 2019 14:38:16 +1100 Subject: [PATCH 4/7] Issue #3250 Ease osgi debugging (#3251) Signed-off-by: Jan Bartel --- .../test/TestJettyOSGiBootContextAsService.java | 12 +++--------- .../jetty/osgi/test/TestJettyOSGiBootHTTP2.java | 15 ++++++++++----- .../test/TestJettyOSGiBootHTTP2Conscrypt.java | 7 ++++--- .../osgi/test/TestJettyOSGiBootHTTP2JDK9.java | 5 +++-- .../test/TestJettyOSGiBootWebAppAsService.java | 9 ++++++--- .../test/TestJettyOSGiBootWithAnnotations.java | 8 +++++--- .../test/TestJettyOSGiBootWithJavaxWebSocket.java | 7 +++---- .../jetty/osgi/test/TestJettyOSGiBootWithJsp.java | 6 +++--- .../osgi/test/TestJettyOSGiBootWithWebSocket.java | 9 ++++----- .../org/eclipse/jetty/osgi/test/TestOSGiUtil.java | 5 +++-- 10 files changed, 44 insertions(+), 39 deletions(-) diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootContextAsService.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootContextAsService.java index 09a5ef097d7..79fcf2cf631 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootContextAsService.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootContextAsService.java @@ -32,7 +32,6 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.handler.ContextHandler; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; @@ -81,19 +80,14 @@ public class TestJettyOSGiBootContextAsService - - @Ignore - public void assertAllBundlesActiveOrResolved() - { - TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext); - } - - /** */ @Test public void testContextHandlerAsOSGiService() throws Exception { + if (Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG)) + TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext); + // now test the context HttpClient client = new HttpClient(); try diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2.java index 6a24a8aa9cc..1dc807119bf 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2.java @@ -41,7 +41,6 @@ import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; @@ -117,8 +116,7 @@ public class TestJettyOSGiBootHTTP2 return res; } - @Ignore - @Test + public void checkALPNBootOnBootstrapClasspath() throws Exception { Class alpn = Thread.currentThread().getContextClassLoader().loadClass("org.eclipse.jetty.alpn.ALPN"); @@ -126,8 +124,7 @@ public class TestJettyOSGiBootHTTP2 assertNull(alpn.getClassLoader()); } - @Ignore - @Test + public void assertAllBundlesActiveOrResolved() throws Exception { TestOSGiUtil.debugBundles(bundleContext); @@ -145,6 +142,14 @@ public class TestJettyOSGiBootHTTP2 @Test public void testHTTP2() throws Exception { + + if (Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG)) + { + checkALPNBootOnBootstrapClasspath(); + assertAllBundlesActiveOrResolved(); + } + + HttpClient httpClient = null; HTTP2Client http2Client = null; try diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java index 6a957b87d3e..02f31dfd7f8 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java @@ -40,7 +40,6 @@ import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; @@ -117,8 +116,7 @@ public class TestJettyOSGiBootHTTP2Conscrypt } - @Ignore - @Test + public void assertAllBundlesActiveOrResolved() throws Exception { TestOSGiUtil.debugBundles(bundleContext); @@ -134,6 +132,9 @@ public class TestJettyOSGiBootHTTP2Conscrypt @Test public void testHTTP2() throws Exception { + if (Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG)) + assertAllBundlesActiveOrResolved(); + HTTP2Client client = new HTTP2Client(); try { diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2JDK9.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2JDK9.java index f002b962f46..ade2e193404 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2JDK9.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootHTTP2JDK9.java @@ -39,7 +39,6 @@ import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; @@ -108,7 +107,6 @@ public class TestJettyOSGiBootHTTP2JDK9 } - @Ignore public void assertAllBundlesActiveOrResolved() throws Exception { TestOSGiUtil.debugBundles(bundleContext); @@ -126,6 +124,9 @@ public class TestJettyOSGiBootHTTP2JDK9 @Test public void testHTTP2() throws Exception { + if (Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG)) + assertAllBundlesActiveOrResolved(); + HttpClient httpClient = null; HTTP2Client http2Client = null; try diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWebAppAsService.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWebAppAsService.java index 64021341faf..2f965ed130a 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWebAppAsService.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWebAppAsService.java @@ -33,7 +33,6 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.webapp.WebAppContext; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; @@ -97,8 +96,7 @@ public class TestJettyOSGiBootWebAppAsService return res; } - @Ignore - @Test + public void assertAllBundlesActiveOrResolved() { TestOSGiUtil.debugBundles(bundleContext); @@ -110,6 +108,11 @@ public class TestJettyOSGiBootWebAppAsService @Test public void testBundle() throws Exception { + + if (Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG)) + assertAllBundlesActiveOrResolved(); + + // now test getting a static file HttpClient client = new HttpClient(); try diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithAnnotations.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithAnnotations.java index c80370c4b73..498161830a0 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithAnnotations.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithAnnotations.java @@ -33,7 +33,6 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.http.HttpStatus; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; @@ -95,10 +94,9 @@ public class TestJettyOSGiBootWithAnnotations } - @Ignore - @Test public void assertAllBundlesActiveOrResolved() { + TestOSGiUtil.debugBundles(bundleContext); TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext); } @@ -107,6 +105,10 @@ public class TestJettyOSGiBootWithAnnotations @Test public void testIndex() throws Exception { + + if (Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG)) + assertAllBundlesActiveOrResolved(); + HttpClient client = new HttpClient(); try { diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithJavaxWebSocket.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithJavaxWebSocket.java index 601719c570b..a4fa70ef546 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithJavaxWebSocket.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithJavaxWebSocket.java @@ -35,7 +35,6 @@ import javax.websocket.RemoteEndpoint; import javax.websocket.Session; import javax.websocket.WebSocketContainer; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; @@ -89,8 +88,6 @@ public class TestJettyOSGiBootWithJavaxWebSocket public static List