From 5ce5737395a084e20b35390b2f061f73728e2ab6 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Thu, 18 Jun 2020 17:45:32 +1000 Subject: [PATCH 1/4] fix information on ThreadPool configuration Signed-off-by: Lachlan Roberts --- .../asciidoc/quick-start/configuring/what-to-configure.adoc | 2 +- jetty-server/src/main/config/modules/threadpool.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jetty-documentation/src/main/asciidoc/quick-start/configuring/what-to-configure.adoc b/jetty-documentation/src/main/asciidoc/quick-start/configuring/what-to-configure.adoc index 438491945d6..9704f4b9fd2 100644 --- a/jetty-documentation/src/main/asciidoc/quick-start/configuring/what-to-configure.adoc +++ b/jetty-documentation/src/main/asciidoc/quick-start/configuring/what-to-configure.adoc @@ -31,7 +31,7 @@ In the standard Jetty distribution, the core server configuration is in `etc/jet ThreadPool:: The Server instance provides a ThreadPool instance that is the default Executor service other Jetty server components use. - The prime configuration of the thread pool is the maximum and minimum size and is set in `start.ini` or `start.d/server.ini`. + The prime configuration of the thread pool is the maximum and minimum size and is set in `start.ini` or `start.d/threadpool.ini`. Handlers:: A Jetty server can have only a single Handler instance to handle incoming HTTP requests. However a handler may be a container or wrapper of other handlers forming a tree of handlers that typically diff --git a/jetty-server/src/main/config/modules/threadpool.mod b/jetty-server/src/main/config/modules/threadpool.mod index c0201b3c7e0..f1a523d7403 100644 --- a/jetty-server/src/main/config/modules/threadpool.mod +++ b/jetty-server/src/main/config/modules/threadpool.mod @@ -16,7 +16,7 @@ etc/jetty-threadpool.xml #jetty.threadPool.maxThreads=200 ## Number of reserved threads (-1 for heuristic) -# jetty.threadPool.reservedThreads=-1 +#jetty.threadPool.reservedThreads=-1 ## Thread Idle Timeout (in milliseconds) #jetty.threadPool.idleTimeout=60000 From fb07bdf159910ec9e660f884413c60c1335666e0 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 7 Jul 2020 11:42:16 +0200 Subject: [PATCH 2/4] Issue #4967 - Possible buffer corruption in HTTP/2 session failures. Fixed test failure after merge. Made sure the lastStreamId is updated when resetting a new stream since it has been seen by the server and handled. This avoids that a new stream arriving during shutdown is interpreted as a connection failure, therefore failing all pending streams - we want them to complete. Signed-off-by: Simone Bordet --- .../src/main/java/org/eclipse/jetty/http2/HTTP2Session.java | 6 +++--- .../org/eclipse/jetty/http2/server/HTTP2ServerSession.java | 1 + 2 files changed, 4 insertions(+), 3 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 d1eeb9a8f33..107cb15be93 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 @@ -693,14 +693,14 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio if (closed.compareAndSet(CloseState.NOT_CLOSED, CloseState.LOCALLY_CLOSED)) { if (LOG.isDebugEnabled()) - LOG.debug("Closing {}/{}", error, reason); + LOG.debug("Closing {}/{} {}", error, reason, this); closeFrame = newGoAwayFrame(CloseState.LOCALLY_CLOSED, error, reason); control(null, callback, closeFrame); return true; } if (LOG.isDebugEnabled()) - LOG.debug("Ignoring close {}/{}, already closed", error, reason); + LOG.debug("Ignoring close {}/{}, already closed {}", error, reason, this); callback.succeeded(); return false; } @@ -1151,7 +1151,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio return lastRemoteStreamId.get(); } - private void updateLastRemoteStreamId(int streamId) + protected void updateLastRemoteStreamId(int streamId) { Atomics.updateMax(lastRemoteStreamId, streamId); } diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java index aa4cf8c43c7..3f91042fd30 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java @@ -106,6 +106,7 @@ public class HTTP2ServerSession extends HTTP2Session implements ServerParser.Lis { if (isClosed()) { + updateLastRemoteStreamId(streamId); reset(new ResetFrame(streamId, ErrorCode.REFUSED_STREAM_ERROR.code), Callback.NOOP); } else From 0808b5c0fcbd99576b8e216a20960c5fd175ee43 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Tue, 7 Jul 2020 14:07:19 +0200 Subject: [PATCH 3/4] Issue #4989 Prevent parsing of module-info.class in osgi bundles (#4991) Signed-off-by: Jan Bartel --- .../jetty/annotations/AnnotationParser.java | 4 +- .../osgi/annotations/AnnotationParser.java | 13 ++- .../test/TestJettyOSGiAnnotationParser.java | 96 ++++++++++++++++++ .../src/test/resources/module-info.clazz | Bin 0 -> 158 bytes .../src/test/resources/module-info.java | 21 ++++ 5 files changed, 129 insertions(+), 5 deletions(-) create mode 100644 jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiAnnotationParser.java create mode 100644 jetty-osgi/test-jetty-osgi/src/test/resources/module-info.clazz create mode 100644 jetty-osgi/test-jetty-osgi/src/test/resources/module-info.java diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java index 1437481b164..a3d5af5cf85 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java @@ -972,7 +972,7 @@ public class AnnotationParser * @param name the class file name * @return whether the class file name is valid */ - private boolean isValidClassFileName(String name) + public boolean isValidClassFileName(String name) { //no name cannot be valid if (name == null || name.length() == 0) @@ -1014,7 +1014,7 @@ public class AnnotationParser * @param path the class file path * @return whether the class file path is valid */ - private boolean isValidClassFilePath(String path) + public boolean isValidClassFilePath(String path) { //no path is not valid if (path == null || path.length() == 0) diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationParser.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationParser.java index 4f51f314e17..482bb4294a0 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationParser.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/annotations/AnnotationParser.java @@ -50,7 +50,7 @@ public class AnnotationParser extends org.eclipse.jetty.annotations.AnnotationPa public AnnotationParser(int javaPlatform) { - super(javaPlatform, Opcodes.ASM7); + super(javaPlatform); } /** @@ -60,7 +60,7 @@ public class AnnotationParser extends org.eclipse.jetty.annotations.AnnotationPa * @return the resource for the bundle * @throws Exception if unable to create the resource reference */ - protected Resource indexBundle(Bundle bundle) throws Exception + public Resource indexBundle(Bundle bundle) throws Exception { File bundleFile = BundleFileLocatorHelperFactory.getFactory().getHelper().getBundleInstallLocation(bundle); Resource resource = Resource.newResource(bundleFile.toURI()); @@ -114,7 +114,7 @@ public class AnnotationParser extends org.eclipse.jetty.annotations.AnnotationPa } } - protected void parse(Set handlers, Bundle bundle) + public void parse(Set handlers, Bundle bundle) throws Exception { URI uri = _bundleToUri.get(bundle); @@ -211,10 +211,17 @@ public class AnnotationParser extends org.eclipse.jetty.annotations.AnnotationPa //or the bundle classpath wasn't simply ".", so skip it continue; } + + if (!isValidClassFileName(name)) + { + continue; //eg skip module-info.class + } + //transform into a classname to pass to the resolver String shortName = StringUtil.replace(name, '/', '.').substring(0, name.length() - 6); addParsedClass(shortName, getResource(bundle)); + try (InputStream classInputStream = classUrl.openStream()) { scanClass(handlers, getResource(bundle), classInputStream); diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiAnnotationParser.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiAnnotationParser.java new file mode 100644 index 00000000000..656485ad850 --- /dev/null +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiAnnotationParser.java @@ -0,0 +1,96 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.osgi.test; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import javax.inject.Inject; + +import aQute.bnd.osgi.Constants; + +import org.eclipse.jetty.annotations.ClassInheritanceHandler; +import org.eclipse.jetty.osgi.annotations.AnnotationParser; +import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.CoreOptions; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.tinybundles.core.TinyBundle; +import org.ops4j.pax.tinybundles.core.TinyBundles; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + +import static org.junit.Assert.assertTrue; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; +/** + * TestJettyOSGiAnnotationParser + * + */ + +@RunWith(PaxExam.class) +public class TestJettyOSGiAnnotationParser +{ + @Inject + BundleContext bundleContext = null; + + @Configuration + public static Option[] configure() + { + ArrayList