454955 OSGi AnnotationParser should skip resources that are not in the classpath and close the class inputstream when done scanning it

This commit is contained in:
Jan Bartel 2014-12-12 15:32:17 +01:00
parent 32c27d146c
commit 8fa2c8ca60
1 changed files with 14 additions and 2 deletions

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.osgi.annotations;
import java.io.File;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.Comparator;
@ -196,10 +197,21 @@ public class AnnotationParser extends org.eclipse.jetty.annotations.AnnotationPa
//remove the starting '/'
name = path.substring(1);
}
if (name == null)
{
//found some .class file in the archive that was not under one of the prefix paths
//or the bundle classpath wasn't simply ".", so skip it
continue;
}
//transform into a classname to pass to the resolver
String shortName = name.replace('/', '.').substring(0,name.length()-6);
if ((resolver == null)|| (!resolver.isExcluded(shortName) && (!isParsed(shortName) || resolver.shouldOverride(shortName))))
scanClass(handlers, getResource(bundle), classUrl.openStream());
if ((resolver == null) || (!resolver.isExcluded(shortName) && (!isParsed(shortName) || resolver.shouldOverride(shortName))))
{
try (InputStream classInputStream = classUrl.openStream())
{
scanClass(handlers, getResource(bundle), classInputStream);
}
}
}
}
}