mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-14 07:43:40 +01:00
Merge pull request #382 from awhitford/MojoStreamClose
Removed unnecessary OutputStream closing.
This commit is contained in:
@@ -931,20 +931,11 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
|
||||
parent.getAbsolutePath()));
|
||||
}
|
||||
|
||||
OutputStream os = null;
|
||||
OutputStream bos = null;
|
||||
ObjectOutputStream out = null;
|
||||
try {
|
||||
if (dependencies != null) {
|
||||
os = new FileOutputStream(file);
|
||||
bos = new BufferedOutputStream(os);
|
||||
out = new ObjectOutputStream(bos);
|
||||
out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
|
||||
out.writeObject(dependencies);
|
||||
out.flush();
|
||||
|
||||
//call reset to prevent resource leaks per
|
||||
//https://www.securecoding.cert.org/confluence/display/java/SER10-J.+Avoid+memory+and+resource+leaks+during+serialization
|
||||
out.reset();
|
||||
}
|
||||
if (getLog().isDebugEnabled()) {
|
||||
getLog().debug(String.format("Serialized data file written to '%s' for %s, referenced by key %s",
|
||||
@@ -967,24 +958,6 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bos != null) {
|
||||
try {
|
||||
bos.close();
|
||||
} catch (IOException ex) {
|
||||
if (getLog().isDebugEnabled()) {
|
||||
getLog().debug("ignore", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (os != null) {
|
||||
try {
|
||||
os.close();
|
||||
} catch (IOException ex) {
|
||||
if (getLog().isDebugEnabled()) {
|
||||
getLog().debug("ignore", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user