Jar Class Loader, a configurable and dynamic custom classloader designed to create, manage and manipulate isolated Java classloaders in IoC frameworks and web applications.
Currently if you add InputStream to jcl instance, it will close it.
This is due to the use of a BufferedInputStream which on close, close underlying inputstream.
This is damageable when you use a ZipInputStream which contains many different jars which has to be loaded into jcl.
Jcl should not close resources give to it.
Bypass is to pass a new instance of an InputStream on each ZipEntry which match jar file.
final JarClassLoader jcl = new JarClassLoader();
try (ZipInputStream zip = new ZipInputStream(stream)) {
ZipEntry entry;
while ((entry = zip.getNextEntry()) != null) {
final String name = entry.getName();
if (name.matches(".*\\.jar")) {
jcl.add(zip);
}
}
}
Currently if you add InputStream to jcl instance, it will close it. This is due to the use of a BufferedInputStream which on close, close underlying inputstream. This is damageable when you use a ZipInputStream which contains many different jars which has to be loaded into jcl. Jcl should not close resources give to it. Bypass is to pass a new instance of an InputStream on each ZipEntry which match jar file.
Problematic code: ` public static void loadJars(final InputStream stream) throws IOException {
}`