From ea116028d423e559c2dbfc9abd34caffb86b3d04 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 13 Mar 2018 14:50:50 -0500 Subject: [PATCH 01/23] Issue #2135 - TLS on Android 8.1 workaround configuration for Direct ByteBuffer use Signed-off-by: Joakim Erdfelt --- .../jetty/io/ssl/SslClientConnectionFactory.java | 14 +++++++++++++- .../org/eclipse/jetty/io/ssl/SslConnection.java | 12 ++++++++++-- .../eclipse/jetty/server/SslConnectionFactory.java | 14 +++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java index 8a8c21ca479..aa81909e5e1 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java @@ -39,6 +39,8 @@ public class SslClientConnectionFactory implements ClientConnectionFactory private final ByteBufferPool byteBufferPool; private final Executor executor; private final ClientConnectionFactory connectionFactory; + private boolean _useDirectBuffersForEncryption = false; + private boolean _useDirectBuffersForDecryption = false; public SslClientConnectionFactory(SslContextFactory sslContextFactory, ByteBufferPool byteBufferPool, Executor executor, ClientConnectionFactory connectionFactory) { @@ -48,6 +50,16 @@ public class SslClientConnectionFactory implements ClientConnectionFactory this.connectionFactory = connectionFactory; } + public void setDirectBuffersForEncryption(boolean useDirectBuffers) + { + this._useDirectBuffersForEncryption = useDirectBuffers; + } + + public void setDirectBuffersForDecryption(boolean useDirectBuffers) + { + this._useDirectBuffersForDecryption = useDirectBuffers; + } + @Override public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map context) throws IOException { @@ -68,6 +80,6 @@ public class SslClientConnectionFactory implements ClientConnectionFactory protected SslConnection newSslConnection(ByteBufferPool byteBufferPool, Executor executor, EndPoint endPoint, SSLEngine engine) { - return new SslConnection(byteBufferPool, executor, endPoint, engine); + return new SslConnection(byteBufferPool, executor, endPoint, engine, _useDirectBuffersForEncryption, _useDirectBuffersForDecryption); } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java index 8284c92e691..c82d6e37a8c 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java @@ -88,8 +88,8 @@ public class SslConnection extends AbstractConnection private ByteBuffer _decryptedInput; private ByteBuffer _encryptedInput; private ByteBuffer _encryptedOutput; - private final boolean _encryptedDirectBuffers = false; - private final boolean _decryptedDirectBuffers = false; + private final boolean _encryptedDirectBuffers; + private final boolean _decryptedDirectBuffers; private final Runnable _runCompletWrite = new Runnable() { @Override @@ -101,6 +101,12 @@ public class SslConnection extends AbstractConnection private boolean _renegotiationAllowed; public SslConnection(ByteBufferPool byteBufferPool, Executor executor, EndPoint endPoint, SSLEngine sslEngine) + { + this(byteBufferPool, executor, endPoint, sslEngine, false, false); + } + + public SslConnection(ByteBufferPool byteBufferPool, Executor executor, EndPoint endPoint, SSLEngine sslEngine, + boolean useDirectBuffersForEncryption, boolean useDirectBuffersForDecryption) { // This connection does not execute calls to onfillable, so they will be called by the selector thread. // onfillable does not block and will only wakeup another thread to do the actual reading and handling. @@ -108,6 +114,8 @@ public class SslConnection extends AbstractConnection this._bufferPool = byteBufferPool; this._sslEngine = sslEngine; this._decryptedEndPoint = newDecryptedEndPoint(); + this._encryptedDirectBuffers = useDirectBuffersForEncryption; + this._decryptedDirectBuffers = useDirectBuffersForDecryption; } protected DecryptedEndPoint newDecryptedEndPoint() diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java b/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java index 679cb7460cc..5e3b15c56c8 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java @@ -34,6 +34,8 @@ public class SslConnectionFactory extends AbstractConnectionFactory { private final SslContextFactory _sslContextFactory; private final String _nextProtocol; + private boolean _useDirectBuffersForEncryption = false; + private boolean _useDirectBuffersForDecryption = false; public SslConnectionFactory() { @@ -58,6 +60,16 @@ public class SslConnectionFactory extends AbstractConnectionFactory return _sslContextFactory; } + public void setDirectBuffersForEncryption(boolean useDirectBuffers) + { + this._useDirectBuffersForEncryption = useDirectBuffers; + } + + public void setDirectBuffersForDecryption(boolean useDirectBuffers) + { + this._useDirectBuffersForDecryption = useDirectBuffers; + } + @Override protected void doStart() throws Exception { @@ -91,7 +103,7 @@ public class SslConnectionFactory extends AbstractConnectionFactory protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine) { - return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine); + return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine, _useDirectBuffersForEncryption, _useDirectBuffersForDecryption); } @Override From 2d5ef67d3f362f073350b551429068ea5fbb5d05 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 6 Jun 2018 10:55:28 -0500 Subject: [PATCH 02/23] Issue #2135 - TLS on Android 8.1 workaround configuration for Direct ByteBuffer use + Changes from review with @sbordet Signed-off-by: Joakim Erdfelt --- .../io/ssl/SslClientConnectionFactory.java | 20 ++++++++++++++----- .../jetty/server/SslConnectionFactory.java | 20 ++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java index aa81909e5e1..8a97784a6fb 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java @@ -39,8 +39,8 @@ public class SslClientConnectionFactory implements ClientConnectionFactory private final ByteBufferPool byteBufferPool; private final Executor executor; private final ClientConnectionFactory connectionFactory; - private boolean _useDirectBuffersForEncryption = false; - private boolean _useDirectBuffersForDecryption = false; + private boolean _directBuffersForEncryption = true; + private boolean _directBuffersForDecryption = true; public SslClientConnectionFactory(SslContextFactory sslContextFactory, ByteBufferPool byteBufferPool, Executor executor, ClientConnectionFactory connectionFactory) { @@ -52,12 +52,22 @@ public class SslClientConnectionFactory implements ClientConnectionFactory public void setDirectBuffersForEncryption(boolean useDirectBuffers) { - this._useDirectBuffersForEncryption = useDirectBuffers; + this._directBuffersForEncryption = useDirectBuffers; } public void setDirectBuffersForDecryption(boolean useDirectBuffers) { - this._useDirectBuffersForDecryption = useDirectBuffers; + this._directBuffersForDecryption = useDirectBuffers; + } + + public boolean isDirectBuffersForDecryption() + { + return _directBuffersForDecryption; + } + + public boolean isDirectBuffersForEncryption() + { + return _directBuffersForEncryption; } @Override @@ -80,6 +90,6 @@ public class SslClientConnectionFactory implements ClientConnectionFactory protected SslConnection newSslConnection(ByteBufferPool byteBufferPool, Executor executor, EndPoint endPoint, SSLEngine engine) { - return new SslConnection(byteBufferPool, executor, endPoint, engine, _useDirectBuffersForEncryption, _useDirectBuffersForDecryption); + return new SslConnection(byteBufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()); } } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java b/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java index 5e3b15c56c8..ec3253e7cbd 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java @@ -34,8 +34,8 @@ public class SslConnectionFactory extends AbstractConnectionFactory { private final SslContextFactory _sslContextFactory; private final String _nextProtocol; - private boolean _useDirectBuffersForEncryption = false; - private boolean _useDirectBuffersForDecryption = false; + private boolean _directBuffersForEncryption = false; + private boolean _directBuffersForDecryption = false; public SslConnectionFactory() { @@ -62,12 +62,22 @@ public class SslConnectionFactory extends AbstractConnectionFactory public void setDirectBuffersForEncryption(boolean useDirectBuffers) { - this._useDirectBuffersForEncryption = useDirectBuffers; + this._directBuffersForEncryption = useDirectBuffers; } public void setDirectBuffersForDecryption(boolean useDirectBuffers) { - this._useDirectBuffersForDecryption = useDirectBuffers; + this._directBuffersForDecryption = useDirectBuffers; + } + + public boolean isDirectBuffersForDecryption() + { + return _directBuffersForDecryption; + } + + public boolean isDirectBuffersForEncryption() + { + return _directBuffersForEncryption; } @Override @@ -103,7 +113,7 @@ public class SslConnectionFactory extends AbstractConnectionFactory protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine) { - return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine, _useDirectBuffersForEncryption, _useDirectBuffersForDecryption); + return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()); } @Override From c4ea4a2d96d46d7fd2237c5f762810df1e2d76a6 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 6 Jun 2018 11:00:03 -0500 Subject: [PATCH 03/23] Issue #2135 - TLS on Android 8.1 workaround configuration for Direct ByteBuffer use + Assigning WebSocket Client to use true for direct bytebuffers always. + Changes from review with @sbordet Signed-off-by: Joakim Erdfelt --- .../websocket/client/io/WebSocketClientSelectorManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java index 1c908d074aa..d282f7c90a9 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java @@ -82,7 +82,7 @@ public class WebSocketClientSelectorManager extends SelectorManager if (sslContextFactory != null) { SSLEngine engine = newSSLEngine(sslContextFactory,channel); - SslConnection sslConnection = new SslConnection(bufferPool,getExecutor(),endPoint,engine); + SslConnection sslConnection = new SslConnection(bufferPool,getExecutor(),endPoint,engine,true,true); sslConnection.setRenegotiationAllowed(sslContextFactory.isRenegotiationAllowed()); EndPoint sslEndPoint = sslConnection.getDecryptedEndPoint(); From df29e292afd49b603d3c5bc9b0d01137378c432c Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 6 Jun 2018 14:24:53 -0500 Subject: [PATCH 04/23] Issue #2135 - Correct testHelloWorld failure by backporting test from 9.4.x Signed-off-by: Joakim Erdfelt --- .../eclipse/jetty/io/SslConnectionTest.java | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java index 2d85210480d..543f7e23792 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java @@ -45,6 +45,7 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.util.thread.TimerScheduler; import org.junit.After; +import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; @@ -139,6 +140,12 @@ public class SslConnectionTest __sslCtxFactory.start(); } + @AfterClass + public static void stopSsl() throws Exception + { + __sslCtxFactory.stop(); + } + @Before public void startManager() throws Exception { @@ -259,27 +266,27 @@ public class SslConnectionTest @Test public void testHelloWorld() throws Exception { - Socket client = newClient(); - client.setSoTimeout(60000); + try (Socket client = newClient()) + { + client.setSoTimeout(60000); + try (SocketChannel server = _connector.accept()) + { + server.configureBlocking(false); + _manager.accept(server); - SocketChannel server = _connector.accept(); - server.configureBlocking(false); - _manager.accept(server); + client.getOutputStream().write("Hello".getBytes(StandardCharsets.UTF_8)); + byte[] buffer = new byte[1024]; + int len = client.getInputStream().read(buffer); + Assert.assertEquals(5, len); + Assert.assertEquals("Hello", new String(buffer, 0, len, StandardCharsets.UTF_8)); - client.getOutputStream().write("Hello".getBytes(StandardCharsets.UTF_8)); - byte[] buffer = new byte[1024]; - int len=client.getInputStream().read(buffer); - Assert.assertEquals(5, len); - Assert.assertEquals("Hello",new String(buffer,0,len,StandardCharsets.UTF_8)); - - _dispatches.set(0); - client.getOutputStream().write("World".getBytes(StandardCharsets.UTF_8)); - len=5; - while(len>0) - len-=client.getInputStream().read(buffer); - Assert.assertEquals(1, _dispatches.get()); - - client.close(); + _dispatches.set(0); + client.getOutputStream().write("World".getBytes(StandardCharsets.UTF_8)); + len = 5; + while (len > 0) + len -= client.getInputStream().read(buffer); + } + } } From 9d9189d47653a71bc2e4643f0f0013f55da69afd Mon Sep 17 00:00:00 2001 From: Venkata Jaswanth <7703387+aj-jaswanth@users.noreply.github.com> Date: Wed, 4 Jul 2018 14:07:08 +0530 Subject: [PATCH 05/23] check for session id in path if url tracking mode is enabled (#2668) Signed-off-by: Venkata Jaswanth U --- .../java/org/eclipse/jetty/server/session/SessionHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java index f96ec1c7cbb..e266a243eea 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java @@ -1654,7 +1654,7 @@ public class SessionHandler extends ScopedHandler } } - if (requested_session_id == null || session == null) + if (isUsingURLs() && (requested_session_id == null || session == null)) { String uri = request.getRequestURI(); From 635cf4d374e854776f536f00e1fa206a00abec04 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 4 Jul 2018 11:12:34 +0200 Subject: [PATCH 06/23] Issue #2349 - Review HTTP/2 max streams enforcement. Restored code that was deleted by mistake. Signed-off-by: Simone Bordet --- .../main/java/org/eclipse/jetty/http2/HTTP2Session.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java index 57b3f4e1499..600c96b1c66 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java @@ -1324,7 +1324,8 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio int length = Math.min(dataRemaining, window); // Only one DATA frame is generated. - int frameBytes = generator.data(lease, (DataFrame)frame, length); + DataFrame dataFrame = (DataFrame)frame; + int frameBytes = generator.data(lease, dataFrame, length); this.frameBytes += frameBytes; this.frameRemaining += frameBytes; @@ -1332,10 +1333,12 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio this.dataBytes += dataBytes; this.dataRemaining -= dataBytes; if (LOG.isDebugEnabled()) - LOG.debug("Generated {}, length/window/data={}/{}/{}", frame, dataBytes, window, dataRemaining); + LOG.debug("Generated {}, length/window/data={}/{}/{}", dataFrame, dataBytes, window, dataRemaining); flowControl.onDataSending(stream, dataBytes); + stream.updateClose(dataFrame.isEndStream(), CloseState.Event.BEFORE_SEND); + return true; } From f6380feef56227fe3eae73b6194cefaa86b28dba Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 5 Jul 2018 14:25:59 +0200 Subject: [PATCH 07/23] Issue #2696 Fix generation of gcloud deps (#2697) Signed-off-by: Jan Bartel --- jetty-gcloud/jetty-gcloud-session-manager/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml index a56e70e4f87..09084d957f2 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml +++ b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml @@ -99,6 +99,7 @@ ${project.build.directory}/deps.txt true org.eclipse.jetty + javax.servlet true runtime @@ -118,7 +119,7 @@ From c45ca9e38bf7f8beaba1dd45e361fae6d8e2962a Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 5 Jul 2018 15:14:42 +0200 Subject: [PATCH 08/23] Issue #2696 Fix syntax of excludedGroupIds for dependency plugin --- jetty-gcloud/jetty-gcloud-session-manager/pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml index 09084d957f2..bfdd0819bc6 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml +++ b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml @@ -98,8 +98,7 @@ false ${project.build.directory}/deps.txt true - org.eclipse.jetty - javax.servlet + org.eclipse.jetty,javax.servlet true runtime From bb1b36b4c60464801b68e25fe09cb28b9ad7dcab Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Fri, 6 Jul 2018 14:41:15 +1000 Subject: [PATCH 09/23] Issue #2685 - bad content in QuotedQualityCSV results in empty entries Signed-off-by: Lachlan Roberts --- .../jetty/http/QuotedQualityCSVTest.java | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/QuotedQualityCSVTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/QuotedQualityCSVTest.java index 32b909bf5e4..a2fbdecc4b9 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/QuotedQualityCSVTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/QuotedQualityCSVTest.java @@ -18,13 +18,16 @@ package org.eclipse.jetty.http; -import static org.hamcrest.Matchers.contains; -import static org.junit.Assert.assertThat; +import java.util.ArrayList; +import java.util.List; import org.hamcrest.Matchers; import org.junit.Assert; import org.junit.Test; +import static org.hamcrest.Matchers.contains; +import static org.junit.Assert.assertThat; + public class QuotedQualityCSVTest { @@ -309,5 +312,44 @@ public class QuotedQualityCSVTest values.addValue("one,two;,three;x=y"); Assert.assertThat(values.getValues(),Matchers.contains("one","two","three;x=y")); } + + + @Test + public void testQuality() + { + List results = new ArrayList<>(); + + QuotedQualityCSV values = new QuotedQualityCSV() + { + @Override + protected void parsedValue(StringBuffer buffer) + { + super.parsedValue(buffer); + results.add("parsedValue: " + buffer.toString()); + } + + @Override + protected void parsedParam(StringBuffer buffer, int valueLength, int paramName, int paramValue) + { + String param = buffer.substring(paramName, buffer.length()); + results.add("parsedParam: " + param); + super.parsedParam(buffer, valueLength, paramName, paramValue); + } + }; + + + /* + The quality value q=0.5 parameter is treated specially, it is consumed and used as the weight for an empty string value + however the parameter p=0.4 is not consumed and is instead added to values + + Note: allowing the q parameter by itself is not specified behaviour in the RFC, but the implementation here is lenient + */ + values.addValue(" en-US;es-ES,q=0.5,p=0.4"); + assertThat(values,contains("en-US;es-ES", "p=0.4", "")); + + assertThat(results,contains("parsedValue: en-US", "parsedParam: es-ES", + "parsedValue: ", "parsedParam: q=0.5", + "parsedValue: ", "parsedParam: p=0.4")); + } } From 8fd5e8563e8f27bc1ae2cdbac5bf8044dccdad04 Mon Sep 17 00:00:00 2001 From: lachan-roberts Date: Mon, 9 Jul 2018 10:52:49 +1000 Subject: [PATCH 10/23] Issue #2685 - bad content in QuotedQualityCSV results in empty entries changes from review Signed-off-by: lachan-roberts --- .../jetty/http/QuotedQualityCSVTest.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/QuotedQualityCSVTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/QuotedQualityCSVTest.java index a2fbdecc4b9..80b4d957450 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/QuotedQualityCSVTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/QuotedQualityCSVTest.java @@ -324,8 +324,9 @@ public class QuotedQualityCSVTest @Override protected void parsedValue(StringBuffer buffer) { - super.parsedValue(buffer); results.add("parsedValue: " + buffer.toString()); + + super.parsedValue(buffer); } @Override @@ -333,23 +334,24 @@ public class QuotedQualityCSVTest { String param = buffer.substring(paramName, buffer.length()); results.add("parsedParam: " + param); + super.parsedParam(buffer, valueLength, paramName, paramValue); } }; - /* - The quality value q=0.5 parameter is treated specially, it is consumed and used as the weight for an empty string value - however the parameter p=0.4 is not consumed and is instead added to values + // The provided string is not legal according to some RFCs ( not a token because of = and not a parameter because not preceded by ; ) + // The string is legal according to RFC7239 which allows for just parameters (called forwarded-pairs) + values.addValue("p=0.5,q=0.5"); - Note: allowing the q parameter by itself is not specified behaviour in the RFC, but the implementation here is lenient - */ - values.addValue(" en-US;es-ES,q=0.5,p=0.4"); - assertThat(values,contains("en-US;es-ES", "p=0.4", "")); - assertThat(results,contains("parsedValue: en-US", "parsedParam: es-ES", - "parsedValue: ", "parsedParam: q=0.5", - "parsedValue: ", "parsedParam: p=0.4")); + // The QuotedCSV implementation is lenient and adopts the later interpretation and thus sees q=0.5 and p=0.5 both as parameters + assertThat(results,contains("parsedValue: ", "parsedParam: p=0.5", + "parsedValue: ", "parsedParam: q=0.5")); + + + // However the QuotedQualityCSV only handles the q parameter and that is consumed from the parameter string. + assertThat(values,contains("p=0.5", "")); + } - } From 1a4d304a0b9c678d628ac033afa83559959fa930 Mon Sep 17 00:00:00 2001 From: lachan-roberts Date: Mon, 9 Jul 2018 11:33:05 +1000 Subject: [PATCH 11/23] Removed unnecessary CACHE.put calls in HttpParser Signed-off-by: lachan-roberts --- .../src/main/java/org/eclipse/jetty/http/HttpParser.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index b8a11df0ab0..9284f75b81e 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -228,12 +228,6 @@ public class HttpParser for (HttpHeader h:HttpHeader.values()) if (!CACHE.put(new HttpField(h,(String)null))) throw new IllegalStateException("CACHE FULL"); - // Add some more common headers - CACHE.put(new HttpField(HttpHeader.REFERER,(String)null)); - CACHE.put(new HttpField(HttpHeader.IF_MODIFIED_SINCE,(String)null)); - CACHE.put(new HttpField(HttpHeader.IF_NONE_MATCH,(String)null)); - CACHE.put(new HttpField(HttpHeader.AUTHORIZATION,(String)null)); - CACHE.put(new HttpField(HttpHeader.COOKIE,(String)null)); } private static HttpCompliance compliance() From 0c8b33e5816d4cdb0f96ab3aa96dfde3f587af4f Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 9 Jul 2018 10:02:45 +0200 Subject: [PATCH 12/23] Fixes #2530 - Client waits forever for cancelled uploads. After discussion on openjdk/nio-dev, we now wakeup the selector after closing a socket, so that the SelectionKey can be removed from the Selector and the TCP stack notified that the socket has been really closed, so that it can send RST to clients. Signed-off-by: Simone Bordet --- .../org/eclipse/jetty/io/ManagedSelector.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java index b77790abff2..5620ab71529 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java @@ -60,6 +60,7 @@ import org.eclipse.jetty.util.thread.strategy.EatWhatYouKill; public class ManagedSelector extends ContainerLifeCycle implements Dumpable { private static final Logger LOG = Log.getLogger(ManagedSelector.class); + private static final SelectorUpdate WAKEUP = new SelectorWakeup(); private final AtomicBoolean _started = new AtomicBoolean(false); private boolean _selecting = false; @@ -101,7 +102,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable _selectorManager.execute(_strategy::produce); // Set started only if we really are started - submit(s->_started.set(true)); + submit(s->_started.set(true)); } public int size() @@ -130,7 +131,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable stop_selector._stopped.await(); } - super.doStop(); + super.doStop(); } /** @@ -236,6 +237,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable public void destroyEndPoint(final EndPoint endPoint) { + submit(WAKEUP); execute(new DestroyEndPoint(endPoint)); } @@ -885,4 +887,18 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable run(); } } + + private static class SelectorWakeup implements SelectorUpdate + { + @Override + public void update(Selector selector) + { + } + + @Override + public String toString() + { + return String.format("%s", getClass().getSimpleName()); + } + } } From 655395727828a1a8c8fdbf253ebb5a2ff3c11435 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 9 Jul 2018 17:26:05 +0200 Subject: [PATCH 13/23] Fixes #2530 - Client waits forever for cancelled uploads. Added comment after review. Signed-off-by: Simone Bordet --- .../src/main/java/org/eclipse/jetty/io/ManagedSelector.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java index 5620ab71529..f0ff037917c 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java @@ -237,6 +237,9 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable public void destroyEndPoint(final EndPoint endPoint) { + // Waking up the selector is necessary to clean the + // cancelled-key set and tell the TCP stack that the + // socket is closed (so that senders receive RST). submit(WAKEUP); execute(new DestroyEndPoint(endPoint)); } From e05c11ae301a20ec2becba746166b95b56b6968c Mon Sep 17 00:00:00 2001 From: lachan-roberts Date: Tue, 10 Jul 2018 10:39:45 +1000 Subject: [PATCH 14/23] Changing default Http headerCacheSize from 512 to 4096 Signed-off-by: lachan-roberts --- .../jetty/client/http/HttpReceiverOverHTTP.java | 2 +- jetty-deploy/src/test/resources/jetty.xml | 2 +- .../asciidoc/development/maven/jetty-maven-plugin.adoc | 2 +- .../jetty/fcgi/parser/ResponseContentParser.java | 2 +- .../jetty/http/HttpGeneratorServerHTTPTest.java | 2 +- .../java/org/eclipse/jetty/http/HttpParserTest.java | 10 ++++------ .../it/jetty-cdi-run-forked/src/main/jetty/jetty.xml | 2 +- .../it/jetty-deploy-war-mojo-it/src/config/jetty.xml | 2 +- .../jetty-simple-webapp/src/config/jetty.xml | 2 +- .../jetty-simple-webapp/src/config/jetty.xml | 2 +- .../jetty-simple-webapp/src/config/jetty.xml | 2 +- .../jetty-simple-webapp/src/config/jetty.xml | 2 +- .../jetty-simple-webapp/src/config/jetty.xml | 2 +- .../run-mojo-gwt-it/beer-server/src/config/jetty.xml | 2 +- jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml | 2 +- .../test-jetty-osgi/src/test/config/etc/jetty.xml | 2 +- jetty-server/src/main/config/etc/jetty.xml | 2 +- jetty-server/src/main/config/modules/server.mod | 2 +- .../org/eclipse/jetty/server/HttpConfiguration.java | 2 +- .../src/test/resources/DefaultHandler.xml | 2 +- .../src/test/resources/RFC2616Base.xml | 2 +- 21 files changed, 24 insertions(+), 26 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java index bdae896e13b..2613e3a44b4 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java @@ -218,7 +218,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res public int getHeaderCacheSize() { // TODO get from configuration - return 256; + return 4096; } @Override diff --git a/jetty-deploy/src/test/resources/jetty.xml b/jetty-deploy/src/test/resources/jetty.xml index a8eaf88911f..00fcd1a9329 100644 --- a/jetty-deploy/src/test/resources/jetty.xml +++ b/jetty-deploy/src/test/resources/jetty.xml @@ -84,7 +84,7 @@ 8192 true false - 512 + 4096