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 1e6621ce8ec..fa4a46c9c53 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 @@ -941,7 +941,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) @@ -983,7 +983,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-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 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 a28bef28592..f4b78fc8f3b 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..71475a2556c --- /dev/null +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiAnnotationParser.java @@ -0,0 +1,95 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 +// +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +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