Directory Watcher leaks ZipInflater
@@ -947,14 +947,7 @@ public class DirectoryWatcher extends Thread implements BundleListener
URL transformed = artifact.getTransformedUrl();
String location = transformed.toString();
BufferedInputStream in = new BufferedInputStream(transformed.openStream());
- try
- {
bundle = installOrUpdateBundle(location, in, artifact.getChecksum(), modified);
- }
- finally
- {
- in.close();
- }
artifact.setBundleId(bundle.getBundleId());
}
// if the listener is an artifact transformer
@@ -968,14 +961,7 @@ public class DirectoryWatcher extends Thread implements BundleListener
File transformed = artifact.getTransformed();
String location = path.toURI().normalize().toString();
BufferedInputStream in = new BufferedInputStream(new FileInputStream(transformed != null ? transformed : path));
- try
- {
bundle = installOrUpdateBundle(location, in, artifact.getChecksum(), modified);
- }
- finally
- {
- in.close();
- }
artifact.setBundleId(bundle.getBundleId());
}
installationFailures.remove(path);
@@ -997,8 +983,10 @@ public class DirectoryWatcher extends Thread implements BundleListener
String bundleLocation, BufferedInputStream is, long checksum, AtomicBoolean modified)
throws IOException, BundleException
{
+ JarInputStream jar = null;
+ try {
is.mark(256 * 1024);
- JarInputStream jar = new JarInputStream(is);
+ jar = new JarInputStream(is);
Manifest m = jar.getManifest();
if( m == null ) {
throw new BundleException(
@@ -1038,13 +1026,20 @@ public class DirectoryWatcher extends Thread implements BundleListener
modified.set(true);
// Set default start level at install time, the user can override it if he wants
- if (startLevel != 0)
- {
+ if (startLevel != 0) {
b.adapt(BundleStartLevel.class).setStartLevel(startLevel);
}
return b;
}
+ finally
+ {
+ if (jar != null)
+ {
+ jar.close();
+ }
+ }
+ }
/**
* Uninstall a jar file.
