Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-10.0.x-…
Browse files Browse the repository at this point in the history
…5018-WebSocketClientRequestTimeout

Signed-off-by: Lachlan Roberts <[email protected]>
  • Loading branch information
lachlan-roberts committed Jul 14, 2020
2 parents 25d7b99 + 7b05567 commit df34a62
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 62 deletions.
12 changes: 7 additions & 5 deletions VERSION.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
jetty-10.0.0-SNAPSHOT

jetty-10.0.0.beta0 - 27 May 2020

jetty-9.4.30.v20200611 - 11 June 2020
+ 4776 Incorrect path matching for WebSocket using PathMappings
+ 4826 Upgrade to Apache Jasper 8.5.54
Expand Down Expand Up @@ -66,7 +68,7 @@ jetty-10.0.0.alpha1 - 26 November 2019
+ 2709 current default for headerCacheSize is not large enough for many
requests
+ 2815 hpack fields are opaque octets
+ 3040 Allow RFC6265 Cookies to include optional SameSite attribute.
+ 3040 Allow RFC6265 Cookies to include optional SameSite attribute
+ 3083 The ini-template for jetty.console-capture.dir does not match the
default value
+ 3106 Websocket connection stats and request stats
Expand Down Expand Up @@ -499,10 +501,10 @@ jetty-9.4.25.v20191220 - 20 December 2019
SslContextFactory usage
+ 4392 Suppress logging of QuietException in HttpChannelState.asyncError()
+ 4402 NPE in JettyRunWarExplodedMojo
+ 4411 Jetty server spins on incomplete request due to delayed dispatch
until content
+ 4415 GzipHandler invalid input zip size on large
(over 2,147,483,647 bytes) request body content
+ 4411 Jetty server spins on incomplete request due to delayed dispatch until
content
+ 4415 GzipHandler invalid input zip size on large (over 2,147,483,647 bytes)
request body content
+ 4421 HttpClient support for PROXY protocol
+ 4427 Retried HttpClient Requests can result in duplicates cookies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ public boolean isClosed()
public Connection acquire(boolean create)
{
Connection connection = activate();
if (connection == null)
if (connection == null && create)
{
if (create)
tryCreate(destination.getQueuedRequestCount());
tryCreate(destination.getQueuedRequestCount());
connection = activate();
}
return connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public Map<String, Object> getAttributes()
}

@Override
public HttpFields.Mutable getHeaders()
public HttpFields getHeaders()
{
return headers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public MultiplexConnectionPool(HttpDestination destination, int maxConnections,
public Connection acquire(boolean create)
{
Connection connection = activate();
if (connection == null)
if (connection == null && create)
{
int queuedRequests = getHttpDestination().getQueuedRequestCount();
int maxMultiplex = getMaxMultiplex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ protected void connect(InetSocketAddress address, ClientConnectionFactory factor
@Override
public void onSettings(Session session, SettingsFrame frame)
{
super.onSettings(session, frame);
// Send another request to simulate a request being
// sent concurrently with connection establishment.
// Sending this request will trigger the creation of
Expand All @@ -199,7 +200,6 @@ public void onSettings(Session session, SettingsFrame frame)
}
});
}
super.onSettings(session, frame);
}
}, promise, context);
}
Expand Down
1 change: 0 additions & 1 deletion jetty-osgi/test-jetty-osgi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
<groupId>org.ops4j.pax.tinybundles</groupId>
<artifactId>tinybundles</artifactId>
<version>3.0.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>biz.aQute.bnd</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -58,20 +59,13 @@ public class TestJettyOSGiAnnotationParser
BundleContext bundleContext = null;

@Configuration
public static Option[] configure()
public static Option[] configure() throws IOException
{
ArrayList<Option> options = new ArrayList<>();
options.add(TestOSGiUtil.optionalRemoteDebug());
options.add(CoreOptions.junitBundles());
options.addAll(TestOSGiUtil.coreJettyDependencies());
options.add(mavenBundle().groupId("biz.aQute.bnd").artifactId("bndlib").versionAsInProject().start());
options.add(mavenBundle().groupId("org.ops4j.pax.tinybundles").artifactId("tinybundles").version("2.1.1").start());
return options.toArray(new Option[options.size()]);
}

@Test
public void testParse() throws Exception
{

//get a reference to a pre-prepared module-info
Path path = Paths.get("src", "test", "resources", "module-info.clazz");
File moduleInfo = path.toFile();
Expand All @@ -80,8 +74,13 @@ public void testParse() throws Exception
TinyBundle bundle = TinyBundles.bundle();
bundle.set(Constants.BUNDLE_SYMBOLICNAME, "bundle.with.module.info");
bundle.add("module-info.class", new FileInputStream(moduleInfo)); //copy it into the fake bundle
InputStream is = bundle.build();
bundleContext.installBundle("dummyLocation", is);
options.add(CoreOptions.streamBundle(bundle.build()).startLevel(1));
return options.toArray(new Option[options.size()]);
}

@Test
public void testParse() throws Exception
{

//test the osgi annotation parser ignore the module-info.class file in the fake bundle
//Get a reference to the deployed fake bundle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpStatus;
Expand Down Expand Up @@ -154,22 +153,26 @@ public List<String> getSubProtocols()

public void setSubProtocols(String... protocols)
{
HttpFields.Mutable headers = getHeaders();
headers.remove(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL);
for (String protocol : protocols)
headers(headers ->
{
headers.add(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL, protocol);
}
headers.remove(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL);
for (String protocol : protocols)
{
headers.add(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL, protocol);
}
});
}

public void setSubProtocols(List<String> protocols)
{
HttpFields.Mutable headers = getHeaders();
headers.remove(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL);
for (String protocol : protocols)
headers(headers ->
{
headers.add(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL, protocol);
}
headers.remove(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL);
for (String protocol : protocols)
{
headers.add(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL, protocol);
}
});
}

@Override
Expand Down Expand Up @@ -282,7 +285,7 @@ void requestComplete()
.collect(Collectors.joining(","));

if (!StringUtil.isEmpty(extensionString))
getHeaders().add(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, extensionString);
headers(headers -> headers.add(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, extensionString));

// Notify the listener which may change the headers directly.
notifyUpgradeListeners((listener) -> listener.onHandshakeRequest(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,12 @@ public void testListenerExtensionSelectionError() throws Exception
upgradeRequest.setSubProtocols("test");
upgradeRequest.addExtensions("permessage-deflate;server_no_context_takeover");

CompletableFuture<String> extensionHeader = new CompletableFuture<>();
upgradeRequest.addListener(new UpgradeListener()
{
@Override
public void onHandshakeRequest(HttpRequest request)
{
request.getHeaders().put(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, "permessage-deflate");
request.headers(headers -> headers.put(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, "permessage-deflate"));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

public class JsrUpgradeListener implements UpgradeListener
{
private Configurator configurator;
private final Configurator configurator;

public JsrUpgradeListener(Configurator configurator)
{
Expand All @@ -46,7 +46,7 @@ public void onHandshakeRequest(HttpRequest request)
if (configurator == null)
return;

HttpFields.Mutable fields = request.getHeaders();
HttpFields fields = request.getHeaders();
Map<String, List<String>> originalHeaders = new HashMap<>();
fields.forEach(field ->
{
Expand All @@ -59,8 +59,11 @@ public void onHandshakeRequest(HttpRequest request)
configurator.beforeRequest(originalHeaders);

// Reset headers on HttpRequest per configurator
fields.clear();
originalHeaders.forEach(fields::put);
request.headers(headers ->
{
headers.clear();
originalHeaders.forEach(headers::put);
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
Expand Down Expand Up @@ -72,11 +71,13 @@ public NetworkFuzzer(LocalServer server, URI wsURI, Map<String, String> requestH
this.upgradeRequest = new RawUpgradeRequest(client, wsURI);
if (requestHeaders != null)
{
HttpFields.Mutable fields = this.upgradeRequest.getHeaders();
requestHeaders.forEach((name, value) ->
this.upgradeRequest.headers(fields ->
{
fields.remove(name);
fields.put(name, value);
requestHeaders.forEach((name, value) ->
{
fields.remove(name);
fields.put(name, value);
});
});
}
this.client.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@

package org.eclipse.jetty.websocket.client.impl;

import java.net.HttpCookie;
import java.net.URI;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import org.eclipse.jetty.client.HttpResponse;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
Expand All @@ -46,11 +47,15 @@ public JettyClientUpgradeRequest(WebSocketCoreClient coreClient, ClientUpgradeRe
if (request != null)
{
// Copy request details into actual request
HttpFields.Mutable fields = getHeaders();
request.getHeaders().forEach(fields::put);
headers(fields -> request.getHeaders().forEach(fields::put));

// Copy manually created Cookies into place
request.getCookies().forEach(c -> fields.add(HttpHeader.COOKIE, c.toString()));
List<HttpCookie> cookies = request.getCookies();
if (cookies != null)
{
// TODO: remove existing Cookie header (if set)?
headers(fields -> cookies.forEach(cookie -> fields.add(HttpHeader.COOKIE, cookie.toString())));
}

// Copy sub-protocols
setSubProtocols(request.getSubProtocols());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public void onMessage(String message) throws IOException
}

@Override
public void onMessage(byte[] buf, int offset, int len)
public void onMessage(byte[] buf, int offset, int len) throws IOException
{
super.onMessage(buf, offset, len);
session.getRemote().sendBytes(ByteBuffer.wrap(buf, offset, len), WriteCallback.NOOP);
session.getRemote().sendBytes(ByteBuffer.wrap(buf, offset, len));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void onMessage(String message) throws IOException
}

@OnWebSocketMessage
public void onMessage(byte[] buf, int offset, int len)
public void onMessage(byte[] buf, int offset, int len) throws IOException
{
ByteBuffer message = ByteBuffer.wrap(buf, offset, len);
if (LOG.isDebugEnabled())
Expand Down
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,14 @@
</goals>
</execution>
</executions>
<!-- this has better support of gh token remove when with next release of jetty-version-maven-plugin -->
<dependencies>
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.114</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,19 @@ public class MongoTestHelper

static MongoClient mongoClient;

static String mongoHost;
static int mongoPort;

public static void startMongo()
{
try
{
long start = System.currentTimeMillis();
mongo.start();
String containerIpAddress = mongo.getContainerIpAddress();
int mongoPort = mongo.getMappedPort(27017);
LOG.info("Mongo container started for {}:{} - {}ms", containerIpAddress, mongoPort,
System.currentTimeMillis() - start);
System.setProperty("embedmongoHost", containerIpAddress);
System.setProperty("embedmongoPort", Integer.toString(mongoPort));
mongoHost = mongo.getHost();
mongoPort = mongo.getMappedPort(27017);
LOG.info("Mongo container started for {}:{} - {}ms", mongoHost, mongoPort,
System.currentTimeMillis() - start);
}
catch (Exception e)
{
Expand All @@ -94,7 +95,7 @@ public static MongoClient getMongoClient() throws UnknownHostException
}
if (mongoClient == null || restart)
{
mongoClient = new MongoClient(System.getProperty("embedmongoHost"), Integer.getInteger("embedmongoPort"));
mongoClient = new MongoClient(mongoHost, mongoPort);
}
return mongoClient;
}
Expand All @@ -117,8 +118,8 @@ public static DBCollection getCollection() throws UnknownHostException, MongoExc
public static MongoSessionDataStoreFactory newSessionDataStoreFactory()
{
MongoSessionDataStoreFactory storeFactory = new MongoSessionDataStoreFactory();
storeFactory.setHost(System.getProperty("embedmongoHost"));
storeFactory.setPort(Integer.getInteger("embedmongoPort"));
storeFactory.setHost(mongoHost);
storeFactory.setPort(mongoPort);
storeFactory.setCollectionName(COLLECTION_NAME);
storeFactory.setDbName(DB_NAME);
return storeFactory;
Expand Down

0 comments on commit df34a62

Please sign in to comment.