Merged branch 'jetty-9.3.x' into 'jetty-9.4.x'.

This commit is contained in:
Simone Bordet 2017-11-08 22:43:48 +01:00
commit d496cc85b6
2 changed files with 26 additions and 26 deletions

View File

@ -69,14 +69,12 @@ import org.objectweb.asm.Opcodes;
public class AnnotationParser
{
private static final Logger LOG = Log.getLogger(AnnotationParser.class);
protected static int ASM_OPCODE_VERSION = Opcodes.ASM6; //compatibility of api
protected Map<String, List<String>> _parsedClassNames = new ConcurrentHashMap<>();
private final int _javaPlatform;
private int _asmVersion;
/**
* Determine the runtime version of asm.
* @return the org.objectweb.asm.Opcode matching the runtime version of asm.
@ -130,6 +128,7 @@ public class AnnotationParser
}
return asmVersion;
}
/**
* Convert internal name to simple name
*
@ -357,37 +356,31 @@ public class AnnotationParser
@Override
public void handle(ClassInfo classInfo)
{
//no-op
}
@Override
public void handle(MethodInfo methodInfo)
{
// no-op
}
@Override
public void handle(FieldInfo fieldInfo)
{
// no-op
}
@Override
public void handle(ClassInfo info, String annotationName)
{
// no-op
}
@Override
public void handle(MethodInfo info, String annotationName)
{
// no-op
}
@Override
public void handle(FieldInfo info, String annotationName)
{
// no-op
}
}
@ -877,20 +870,20 @@ public class AnnotationParser
LOG.debug("Scanning jar {}", jarResource);
MultiException me = new MultiException();
MultiReleaseJarFile jarFile = new MultiReleaseJarFile(jarResource.getFile(),_javaPlatform,false);
jarFile.stream().forEach(e->
try (MultiReleaseJarFile jarFile = new MultiReleaseJarFile(jarResource.getFile(),_javaPlatform,false))
{
try
jarFile.stream().forEach(e->
{
parseJarEntry(handlers, jarResource, e);
}
catch (Exception ex)
{
me.add(new RuntimeException("Error scanning entry " + e.getName() + " from jar " + jarResource, ex));
}
});
try
{
parseJarEntry(handlers, jarResource, e);
}
catch (Exception ex)
{
me.add(new RuntimeException("Error scanning entry " + e.getName() + " from jar " + jarResource, ex));
}
});
}
me.ifExceptionThrow();
}
}

View File

@ -18,11 +18,13 @@
package org.eclipse.jetty.util;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.jar.JarEntry;
@ -33,7 +35,7 @@ import java.util.stream.Stream;
/**
* <p>Utility class to handle a Multi Release Jar file</p>
*/
public class MultiReleaseJarFile
public class MultiReleaseJarFile implements Closeable
{
private static final String META_INF_VERSIONS = "META-INF/versions/";
@ -84,12 +86,10 @@ public class MultiReleaseJarFile
{
Map.Entry<String,VersionedJarEntry> e = i.next();
VersionedJarEntry entry = e.getValue();
if (entry.inner)
{
VersionedJarEntry outer = entry.outer==null?null:map.get(entry.outer);
if (entry.outer==null || outer==null || outer.version!= entry.version)
if (outer==null || outer.version!=entry.version)
i.remove();
}
}
@ -130,6 +130,13 @@ public class MultiReleaseJarFile
return entries.get(name);
}
@Override
public void close() throws IOException
{
if (jarFile!=null)
jarFile.close();
}
@Override
public String toString()
{
@ -172,8 +179,8 @@ public class MultiReleaseJarFile
this.entry = entry;
this.name = name;
this.version = v;
this.inner = name.contains("$") && name.toLowerCase().endsWith(".class");
this.outer = inner ? name.substring(0, name.indexOf('$')) + name.substring(name.length() - 6, name.length()) : null;
this.inner = name.contains("$") && name.toLowerCase(Locale.ENGLISH).endsWith(".class");
this.outer = inner ? name.substring(0, name.indexOf('$')) + ".class" : null;
}
/**