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 cdf3b8dda4e..1c16dd17117 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 @@ -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> _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(); } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java index 324d9faaaff..ec0bdb8b19e 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java @@ -618,7 +618,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable } } - private class CreateEndPoint extends Invocable.NonBlocking implements Closeable + private class CreateEndPoint implements Runnable, Invocable, Closeable { private final SelectableChannel channel; private final SelectionKey key; @@ -809,7 +809,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable } } - private class DestroyEndPoint extends Invocable.NonBlocking implements Closeable + private class DestroyEndPoint implements Runnable, Invocable, Closeable { private final EndPoint endPoint; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiReleaseJarFile.java b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiReleaseJarFile.java index 506731c8f23..3a9c0759e50 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiReleaseJarFile.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiReleaseJarFile.java @@ -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; /** *

Utility class to handle a Multi Release Jar file

*/ -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 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; } /**