Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-11.0.x
This commit is contained in:
commit
872b2741be
|
@ -941,7 +941,7 @@ public class AnnotationParser
|
||||||
* @param name the class file name
|
* @param name the class file name
|
||||||
* @return whether the class file name is valid
|
* @return whether the class file name is valid
|
||||||
*/
|
*/
|
||||||
private boolean isValidClassFileName(String name)
|
public boolean isValidClassFileName(String name)
|
||||||
{
|
{
|
||||||
//no name cannot be valid
|
//no name cannot be valid
|
||||||
if (name == null || name.length() == 0)
|
if (name == null || name.length() == 0)
|
||||||
|
@ -983,7 +983,7 @@ public class AnnotationParser
|
||||||
* @param path the class file path
|
* @param path the class file path
|
||||||
* @return whether the class file path is valid
|
* @return whether the class file path is valid
|
||||||
*/
|
*/
|
||||||
private boolean isValidClassFilePath(String path)
|
public boolean isValidClassFilePath(String path)
|
||||||
{
|
{
|
||||||
//no path is not valid
|
//no path is not valid
|
||||||
if (path == null || path.length() == 0)
|
if (path == null || path.length() == 0)
|
||||||
|
|
|
@ -693,14 +693,14 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
if (closed.compareAndSet(CloseState.NOT_CLOSED, CloseState.LOCALLY_CLOSED))
|
if (closed.compareAndSet(CloseState.NOT_CLOSED, CloseState.LOCALLY_CLOSED))
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Closing {}/{}", error, reason);
|
LOG.debug("Closing {}/{} {}", error, reason, this);
|
||||||
closeFrame = newGoAwayFrame(CloseState.LOCALLY_CLOSED, error, reason);
|
closeFrame = newGoAwayFrame(CloseState.LOCALLY_CLOSED, error, reason);
|
||||||
control(null, callback, closeFrame);
|
control(null, callback, closeFrame);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Ignoring close {}/{}, already closed", error, reason);
|
LOG.debug("Ignoring close {}/{}, already closed {}", error, reason, this);
|
||||||
callback.succeeded();
|
callback.succeeded();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1151,7 +1151,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
return lastRemoteStreamId.get();
|
return lastRemoteStreamId.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLastRemoteStreamId(int streamId)
|
protected void updateLastRemoteStreamId(int streamId)
|
||||||
{
|
{
|
||||||
Atomics.updateMax(lastRemoteStreamId, streamId);
|
Atomics.updateMax(lastRemoteStreamId, streamId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,7 @@ public class HTTP2ServerSession extends HTTP2Session implements ServerParser.Lis
|
||||||
{
|
{
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
{
|
{
|
||||||
|
updateLastRemoteStreamId(streamId);
|
||||||
reset(new ResetFrame(streamId, ErrorCode.REFUSED_STREAM_ERROR.code), Callback.NOOP);
|
reset(new ResetFrame(streamId, ErrorCode.REFUSED_STREAM_ERROR.code), Callback.NOOP);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class AnnotationParser extends org.eclipse.jetty.annotations.AnnotationPa
|
||||||
|
|
||||||
public AnnotationParser(int javaPlatform)
|
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
|
* @return the resource for the bundle
|
||||||
* @throws Exception if unable to create the resource reference
|
* @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);
|
File bundleFile = BundleFileLocatorHelperFactory.getFactory().getHelper().getBundleInstallLocation(bundle);
|
||||||
Resource resource = Resource.newResource(bundleFile.toURI());
|
Resource resource = Resource.newResource(bundleFile.toURI());
|
||||||
|
@ -114,7 +114,7 @@ public class AnnotationParser extends org.eclipse.jetty.annotations.AnnotationPa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void parse(Set<? extends Handler> handlers, Bundle bundle)
|
public void parse(Set<? extends Handler> handlers, Bundle bundle)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
URI uri = _bundleToUri.get(bundle);
|
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
|
//or the bundle classpath wasn't simply ".", so skip it
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isValidClassFileName(name))
|
||||||
|
{
|
||||||
|
continue; //eg skip module-info.class
|
||||||
|
}
|
||||||
|
|
||||||
//transform into a classname to pass to the resolver
|
//transform into a classname to pass to the resolver
|
||||||
String shortName = StringUtil.replace(name, '/', '.').substring(0, name.length() - 6);
|
String shortName = StringUtil.replace(name, '/', '.').substring(0, name.length() - 6);
|
||||||
|
|
||||||
addParsedClass(shortName, getResource(bundle));
|
addParsedClass(shortName, getResource(bundle));
|
||||||
|
|
||||||
try (InputStream classInputStream = classUrl.openStream())
|
try (InputStream classInputStream = classUrl.openStream())
|
||||||
{
|
{
|
||||||
scanClass(handlers, getResource(bundle), classInputStream);
|
scanClass(handlers, getResource(bundle), classInputStream);
|
||||||
|
|
|
@ -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<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();
|
||||||
|
assertTrue(moduleInfo.exists());
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
//test the osgi annotation parser ignore the module-info.class file in the fake bundle
|
||||||
|
//Get a reference to the deployed fake bundle
|
||||||
|
Bundle b = TestOSGiUtil.getBundle(bundleContext, "bundle.with.module.info");
|
||||||
|
AnnotationParser parser = new AnnotationParser(0);
|
||||||
|
parser.indexBundle(b);
|
||||||
|
ClassInheritanceHandler handler = new ClassInheritanceHandler(new ConcurrentHashMap<>());
|
||||||
|
parser.parse(Collections.singleton(handler), b);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,21 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// 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
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
module com.bubble
|
||||||
|
{
|
||||||
|
}
|
Loading…
Reference in New Issue