mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-13 23:33:37 +01:00
Removed unnecessary OutputStream closing. Also the flush and reset are not necessary since the stream is being closed right away.
This commit is contained in:
@@ -918,20 +918,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",
|
||||
@@ -954,24 +945,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