Merge branch 'jetty-10.0.x' into jetty-10.0.x-3167-websocket-mapping

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2019-01-15 17:59:09 +11:00
commit 4a70d1534e
14 changed files with 83 additions and 75 deletions

View File

@ -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 to next is not a legal state transition (api usage error)
*/
private boolean updateState(State previous, State next)
{

View File

@ -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

View File

@ -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
{

View File

@ -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

View File

@ -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

View File

@ -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
{

View File

@ -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;
@ -91,6 +90,7 @@ public class TestJettyOSGiBootWithJavaxWebSocket
public static List<Option> testJettyWebApp()
{
List<Option> res = new ArrayList<>();
//test webapp bundle
res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("test-jetty-webapp").classifier("webbundle").versionAsInProject().noStart());
return res;
}
@ -102,16 +102,9 @@ public class TestJettyOSGiBootWithJavaxWebSocket
return res;
}
@Ignore
public void assertAllBundlesActiveOrResolved() throws BundleException
public void assertAllBundlesActiveOrResolved()
{
fixJavaxWebSocketApi();
startBundle(bundleContext, "org.eclipse.jetty.websocket.javax.websocket.common");
startBundle(bundleContext, "org.eclipse.jetty.websocket.javax.websocket.client");
startBundle(bundleContext, "org.eclipse.jetty.websocket.javax.websocket.server");
startBundle(bundleContext, "org.eclipse.jetty.tests.webapp");
TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext);
TestOSGiUtil.debugBundles(bundleContext);
}
@ -119,6 +112,7 @@ public class TestJettyOSGiBootWithJavaxWebSocket
@Test
public void testWebsocket() throws Exception
{
fixJavaxWebSocketApi();
startBundle(bundleContext, "org.eclipse.jetty.websocket.javax.websocket.common");
@ -126,6 +120,9 @@ public class TestJettyOSGiBootWithJavaxWebSocket
startBundle(bundleContext, "org.eclipse.jetty.websocket.javax.websocket.server");
startBundle(bundleContext, "org.eclipse.jetty.tests.webapp");
if (Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG))
assertAllBundlesActiveOrResolved();
String port = System.getProperty("boot.javax.websocket.port");
assertNotNull(port);

View File

@ -32,7 +32,6 @@ import javax.inject.Inject;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
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;
@ -86,8 +85,6 @@ public class TestJettyOSGiBootWithJsp
}
@Ignore
@Test
public void assertAllBundlesActiveOrResolved()
{
TestOSGiUtil.debugBundles(bundleContext);
@ -98,6 +95,9 @@ public class TestJettyOSGiBootWithJsp
@Test
public void testJspDump() throws Exception
{
if (Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG))
assertAllBundlesActiveOrResolved();
HttpClient client = new HttpClient();
try
{

View File

@ -32,7 +32,6 @@ import javax.inject.Inject;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
@ -85,7 +84,6 @@ public class TestJettyOSGiBootWithWebSocket
}
@Ignore
public void assertAllBundlesActiveOrResolved()
{
TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext);
@ -96,7 +94,10 @@ public class TestJettyOSGiBootWithWebSocket
@Test
public void testWebsocket() throws Exception
{
{
if (Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG))
assertAllBundlesActiveOrResolved();
String port = System.getProperty("boot.websocket.port");
assertNotNull(port);

View File

@ -44,7 +44,6 @@ import org.eclipse.jetty.osgi.boot.OSGiServerConstants;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.osgi.framework.Bundle;
@ -57,6 +56,8 @@ import org.osgi.service.http.HttpService;
*/
public class TestOSGiUtil
{
public static final String BUNDLE_DEBUG = "bundle.debug";
public static List<Option> configureJettyHomeAndPort(boolean ssl,String jettySelectorFileName)
{
@ -103,7 +104,7 @@ public class TestOSGiUtil
public static List<Option> coreJettyDependencies()
{
List<Option> res = new ArrayList<>();
res.add(systemProperty("bundle.debug").value(Boolean.toString(Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG))));
String mavenRepoPath = System.getProperty( "mavenRepoPath" );
if (!StringUtil.isBlank(mavenRepoPath))
res.add( systemProperty( "org.ops4j.pax.url.mvn.localRepository" ).value( mavenRepoPath ) );

View File

@ -45,7 +45,7 @@ import org.eclipse.jetty.websocket.core.internal.Generator;
public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseable
{
private final LocalServer server;
private final RawWebSocketClient rawClient;
private final WebSocketCoreClient client;
private final RawUpgradeRequest upgradeRequest;
private final UnitGenerator generator;
private final FrameCapture frameCapture;
@ -65,9 +65,9 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
{
super();
this.server = server;
this.rawClient = new RawWebSocketClient();
this.client = new WebSocketCoreClient();
CompletableFuture<FrameCapture> futureOnCapture = new CompletableFuture<>();
this.upgradeRequest = new RawUpgradeRequest(rawClient, wsURI, futureOnCapture);
this.upgradeRequest = new RawUpgradeRequest(client, wsURI, futureOnCapture);
if (requestHeaders != null)
{
HttpFields fields = this.upgradeRequest.getHeaders();
@ -77,10 +77,10 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
fields.put(name, value);
});
}
this.rawClient.start();
this.client.start();
this.generator = new UnitGenerator(Behavior.CLIENT);
CompletableFuture<FrameHandler.CoreSession> futureHandler = this.rawClient.connect(upgradeRequest);
CompletableFuture<FrameHandler.CoreSession> futureHandler = this.client.connect(upgradeRequest);
CompletableFuture<FrameCapture> futureCapture = futureHandler.thenCombine(futureOnCapture, (channel, capture) -> capture);
this.frameCapture = futureCapture.get(10, TimeUnit.SECONDS);
}
@ -102,7 +102,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
@Override
public void close() throws Exception
{
this.rawClient.stop();
this.client.stop();
}
@Override
@ -156,7 +156,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
{
try (SharedBlockingCallback.Blocker blocker = sharedBlockingCallback.acquire())
{
frameCapture.channel.sendFrame(f, blocker, false);
frameCapture.session.sendFrame(f, blocker, false);
}
}
}
@ -168,7 +168,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
{
try (SharedBlockingCallback.Blocker blocker = sharedBlockingCallback.acquire())
{
frameCapture.channel.sendFrame(f, blocker, false);
frameCapture.session.sendFrame(f, blocker, false);
}
}
}
@ -184,10 +184,6 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
}
}
public static class RawWebSocketClient extends WebSocketCoreClient
{
}
public static class RawUpgradeRequest extends UpgradeRequest
{
private final CompletableFuture<FrameCapture> futureCapture;
@ -226,7 +222,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
private final BlockingQueue<Frame> receivedFrames = new LinkedBlockingQueue<>();
private final EndPoint endPoint;
private final SharedBlockingCallback blockingCallback = new SharedBlockingCallback();
private CoreSession channel;
private CoreSession session;
public FrameCapture(EndPoint endPoint)
{
@ -247,20 +243,26 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
public void onFrame(Frame frame, Callback callback)
{
receivedFrames.offer(Frame.copy(frame));
callback.succeeded();
synchronized(this)
{
callback.succeeded();
}
}
@Override
public void onOpen(CoreSession coreSession) throws Exception
{
this.channel = coreSession;
this.session = coreSession;
}
public void writeRaw(ByteBuffer buffer) throws IOException
{
try (SharedBlockingCallback.Blocker blocker = blockingCallback.acquire())
synchronized (this)
{
this.endPoint.write(blocker, buffer);
try (SharedBlockingCallback.Blocker blocker = blockingCallback.acquire())
{
this.endPoint.write(blocker, buffer);
}
}
}
}

View File

@ -18,9 +18,6 @@
package org.eclipse.jetty.websocket.javax.tests.client;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
@ -51,6 +48,9 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class DecoderReaderManySmallTest
{
private CoreServer server;
@ -91,12 +91,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<Integer> seen = new ArrayList<>();
@ -182,6 +184,8 @@ public class DecoderReaderManySmallTest
sendText(Integer.toString(id), Callback.NOOP, false);
}
}
getCoreSession().flush(callback);
}
}
}

View File

@ -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);

View File

@ -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.
*/
@ -359,7 +359,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)