modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginClassLoader.java
| 12 +++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
| 14 +++++-----
2 files changed, 15 insertions(+), 11 deletions(-)
New commits:
commit 7db43fdbd624ec1227a1d7745b67b59f39a9fe1e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 14:07:38 2011 -0400
[coverity] paranoia - just make sure we always close the file stream, avoiding the
possibility that Buffered stream constructor bombs would leave the file stream open
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginClassLoader.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginClassLoader.java
index 25be7de..a9b07f2 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginClassLoader.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginClassLoader.java
@@ -205,21 +205,24 @@ public class PluginClassLoader extends URLClassLoader {
}
}
- BufferedOutputStream outputStream;
+ FileOutputStream fileOutputStream;
try {
- outputStream = new BufferedOutputStream(new
FileOutputStream(file));
+ fileOutputStream = new FileOutputStream(file);
} catch (FileNotFoundException ex) {
if (file.exists() && (file.length() > 0)) {
// e.g. on win32, agent running w/ dll loaded
PluginDumper cannot overwrite file inuse.
continue;
}
-
throw ex;
}
+ BufferedOutputStream outputStream = new
BufferedOutputStream(fileOutputStream);
try {
file.deleteOnExit();
+ // do NOT close this inputStream since it is buffering the
ZipInputStream
+ // and we are going to still process that input stream later.
We close
+ // this ZipInputStream down below in the outer most
try-finally block.
BufferedInputStream inputStream = new
BufferedInputStream(zis);
int count;
@@ -229,13 +232,12 @@ public class PluginClassLoader extends URLClassLoader {
}
} finally {
outputStream.flush();
- outputStream.close();
+ outputStream.close(); // this also closes the
fileOutputStream
}
} catch (IOException ioe) {
if (file != null) {
file.delete();
}
-
throw ioe;
}
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
index fa26970..90e2117 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
@@ -133,37 +133,39 @@ public class ServerPluginClassLoader extends URLClassLoader {
}
}
- BufferedOutputStream outputStream;
+ FileOutputStream fileOutputStream;
try {
- outputStream = new BufferedOutputStream(new
FileOutputStream(file));
+ fileOutputStream = new FileOutputStream(file);
} catch (FileNotFoundException ex) {
if (file.exists() && (file.length() > 0)) {
// e.g. on win32, agent running w/ dll loaded
PluginDumper cannot overwrite file inuse.
continue;
}
-
throw ex;
}
+ BufferedOutputStream outputStream = new
BufferedOutputStream(fileOutputStream);
try {
file.deleteOnExit();
+ // do NOT close this inputStream since it is buffering the
ZipInputStream
+ // and we are going to still process that input stream later.
We close
+ // this ZipInputStream down below in the outer most
try-finally block.
BufferedInputStream inputStream = new
BufferedInputStream(zis);
- int count = 0;
+ int count;
byte[] b = new byte[8192];
while ((count = inputStream.read(b)) > -1) {
outputStream.write(b, 0, count);
}
} finally {
outputStream.flush();
- outputStream.close();
+ outputStream.close(); // this also closes the
fileOutputStream
}
} catch (IOException ioe) {
if (file != null) {
file.delete();
}
-
throw ioe;
}
}
Show replies by date