From b191d69bb07f7e5c4c52f9187009a9f72c8bb611 Mon Sep 17 00:00:00 2001 From: Steven Schlansker Date: Wed, 21 Nov 2018 02:38:03 -0800 Subject: [PATCH 1/3] bom: inherit project; use flatten plugin to sanitize bom (#3114) Signed-off-by: Steven Schlansker --- jetty-bom/pom.xml | 198 +++++++++------------------------------------- 1 file changed, 38 insertions(+), 160 deletions(-) diff --git a/jetty-bom/pom.xml b/jetty-bom/pom.xml index a34b1206a39..f95fff12893 100644 --- a/jetty-bom/pom.xml +++ b/jetty-bom/pom.xml @@ -1,92 +1,51 @@ - org.eclipse.jetty 4.0.0 jetty-bom - 9.4.15-SNAPSHOT Jetty :: Bom Jetty BOM artifact http://www.eclipse.org/jetty - 1995 pom - - github - https://github.com/eclipse/jetty.project/issues - - - - - Apache Software License - Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0 - - - Eclipse Public License - Version 1.0 - http://www.eclipse.org/org/documents/epl-v10.php - - - - - http://www.eclipse.org/jetty - UTF-8 - 1.4 - - - - scm:git:https://github.com/eclipse/jetty.project.git - scm:git:git@github.com:eclipse/jetty.project.git - https://github.com/eclipse/jetty.project - - - - - oss.sonatype.org - Jetty Staging Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - oss.sonatype.org - Jetty Snapshot Repository - https://oss.sonatype.org/content/repositories/jetty-snapshots/ - - - jetty.eclipse.website - scp://build.eclipse.org:/home/data/httpd/download.eclipse.org/jetty/${project.version}/ - - + + org.eclipse.jetty + jetty-project + 9.4.15-SNAPSHOT + - - - - org.apache.maven.plugins - maven-release-plugin - 2.5.3 - - false - deploy - -Peclipse-release - clean install - forked-path - - - - org.apache.maven.plugins - maven-source-plugin - 3.0.1 - - true - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.0 - - true - - - - + + + org.codehaus.mojo + flatten-maven-plugin + 1.0.1 + + ${project.build.directory} + flattened-pom.xml + bom + true + + remove + remove + + + + + flatten + + flatten + + process-resources + + + flatten-clean + + clean + + clean + + + + @@ -422,85 +381,4 @@ - - - - gregw - Greg Wilkins - gregw@webtide.com - Webtide, LLC - https://webtide.com - 10 - - - janb - Jan Bartel - janb@webtide.com - Webtide, LLC - https://webtide.com - 10 - - - jesse - Jesse McConnell - jesse.mcconnell@gmail.com - Webtide, LLC - https://webtide.com - -6 - - - joakime - Joakim Erdfelt - joakim.erdfelt@gmail.com - Webtide, LLC - https://webtide.com - -6 - - - sbordet - Simone Bordet - simone.bordet@gmail.com - Webtide, LLC - https://webtide.com - 1 - - - djencks - David Jencks - david.a.jencks@gmail.com - IBM - -8 - - - - - - eclipse-release - - - - true - org.apache.maven.plugins - maven-deploy-plugin - - true - - - - org.apache.maven.plugins - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - - - - - - From 041e8fd9cfab4c6719c8a210f2570a07d9f7eb65 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 21 Nov 2018 17:28:40 +0100 Subject: [PATCH 2/3] Issue #3038 SSL Connection Leak Don't call handleContentMessage after content call if the content call returns true. This is a slight bending of the parser contract to work around the current client interpretation that a true return will prevent other events from being delivered. Signed-off-by: Greg Wilkins --- .../jetty/client/http/HttpReceiverOverHTTP.java | 17 ----------------- .../java/org/eclipse/jetty/http/HttpParser.java | 8 +++----- 2 files changed, 3 insertions(+), 22 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 3be68769bb5..d6a9c2f96a5 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 @@ -20,7 +20,6 @@ package org.eclipse.jetty.client.http; import java.io.EOFException; import java.nio.ByteBuffer; -import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpExchange; @@ -40,7 +39,6 @@ import org.eclipse.jetty.util.CompletableCallback; public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.ResponseHandler { - private final AtomicReference handlingContent = new AtomicReference<>(ContentState.IDLE); private final HttpParser parser; private ByteBuffer buffer; private boolean shutdown; @@ -265,18 +263,8 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res if (exchange == null) return false; - handlingContent.set(ContentState.CONTENT); CompletableCallback callback = new CompletableCallback() { - @Override - public void succeeded() - { - boolean messageComplete = !handlingContent.compareAndSet(ContentState.CONTENT, ContentState.IDLE); - super.succeeded(); - if (messageComplete) - messageComplete(); - } - @Override public void resume() { @@ -316,9 +304,6 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res @Override public boolean messageComplete() { - if (handlingContent.compareAndSet(ContentState.CONTENT, ContentState.COMPLETE)) - return false; - HttpExchange exchange = getHttpExchange(); if (exchange == null) return false; @@ -390,6 +375,4 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res { return String.format("%s[%s]", super.toString(), parser); } - - private enum ContentState { IDLE, CONTENT, COMPLETE } } 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 3c0405e9cf7..a00e3e6c49a 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 @@ -1660,16 +1660,14 @@ public class HttpParser _contentPosition += _contentChunk.remaining(); buffer.position(buffer.position()+_contentChunk.remaining()); - boolean handle = _handler.content(_contentChunk); + if (_handler.content(_contentChunk)) + return true; if(_contentPosition == _contentLength) { setState(State.END); - boolean handleContent = handleContentMessage(); - return handle || handleContent; + return handleContentMessage(); } - else if (handle) - return true; } break; } From 910665a55a4ef16ff6cd55a1c1799c20ff76db65 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 21 Nov 2018 17:37:16 +0100 Subject: [PATCH 3/3] Fixes #3133 - Logging of key.readyOps() can throw unchecked CancelledKeyException. Introduced safeInterestOps() and safeReadyOps() to catch exceptions they may throw and using them in relevant places to fix the issue. Signed-off-by: Simone Bordet --- .../org/eclipse/jetty/io/ChannelEndPoint.java | 23 +++------- .../org/eclipse/jetty/io/ManagedSelector.java | 45 +++++++++++++------ 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java index 0421176298f..84e80276e28 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java @@ -31,7 +31,6 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.Invocable; -import org.eclipse.jetty.util.thread.Locker; import org.eclipse.jetty.util.thread.Scheduler; /** @@ -426,21 +425,11 @@ public abstract class ChannelEndPoint extends AbstractEndPoint implements Manage public String toEndPointString() { // We do a best effort to print the right toString() and that's it. - try - { - boolean valid = _key != null && _key.isValid(); - int keyInterests = valid ? _key.interestOps() : -1; - int keyReadiness = valid ? _key.readyOps() : -1; - return String.format("%s{io=%d/%d,kio=%d,kro=%d}", - super.toEndPointString(), - _currentInterestOps, - _desiredInterestOps, - keyInterests, - keyReadiness); - } - catch (Throwable x) - { - return String.format("%s{io=%s,kio=-2,kro=-2}", super.toString(), _desiredInterestOps); - } + return String.format("%s{io=%d/%d,kio=%d,kro=%d}", + super.toEndPointString(), + _currentInterestOps, + _desiredInterestOps, + ManagedSelector.safeInterestOps(_key), + ManagedSelector.safeReadyOps(_key)); } } 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 75e67386bad..b379c60a25c 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 @@ -272,6 +272,34 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable } } + static int safeReadyOps(SelectionKey selectionKey) + { + try + { + return selectionKey.readyOps(); + } + catch (Throwable x) + { + if (LOG.isDebugEnabled()) + LOG.debug(x); + return -1; + } + } + + static int safeInterestOps(SelectionKey selectionKey) + { + try + { + return selectionKey.interestOps(); + } + catch (Throwable x) + { + if (LOG.isDebugEnabled()) + LOG.debug(x); + return -1; + } + } + @Override public void dump(Appendable out, String indent) throws IOException { @@ -474,7 +502,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable { Object attachment = key.attachment(); if (LOG.isDebugEnabled()) - LOG.debug("selected {} {} {} ",key.readyOps(),key,attachment); + LOG.debug("selected {} {} {} ", safeReadyOps(key), key, attachment); try { if (attachment instanceof Selectable) @@ -490,7 +518,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable } else { - throw new IllegalStateException("key=" + key + ", att=" + attachment + ", iOps=" + key.interestOps() + ", rOps=" + key.readyOps()); + throw new IllegalStateException("key=" + key + ", att=" + attachment + ", iOps=" + safeInterestOps(key) + ", rOps=" + safeReadyOps(key)); } } catch (CancelledKeyException x) @@ -571,19 +599,10 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable List list = new ArrayList<>(selector_keys.size()); for (SelectionKey key : selector_keys) { - if (key==null) - continue; - try - { - list.add(String.format("SelectionKey@%x{i=%d}->%s", key.hashCode(), key.interestOps(), key.attachment())); - } - catch (Throwable x) - { - list.add(String.format("SelectionKey@%x[%s]->%s", key.hashCode(), x, key.attachment())); - } + if (key != null) + list.add(String.format("SelectionKey@%x{i=%d}->%s", key.hashCode(), safeInterestOps(key), key.attachment())); } keys = list; - latch.countDown(); }