Skip to content

Commit

Permalink
[CID-1205053] - Resource leak on fingerprint calculation in Directory…
Browse files Browse the repository at this point in the history
…BrowserSupport

The issue is related to JENKINS-18351.

Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
  • Loading branch information
oleg-nenashev committed Nov 4, 2014
1 parent 21ba31a commit 2ea0276
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/src/main/java/hudson/model/DirectoryBrowserSupport.java
Expand Up @@ -284,7 +284,12 @@ private void serveFile(StaplerRequest req, StaplerResponse rsp, VirtualFile root
boolean view = rest.equals("*view*");

if(rest.equals("*fingerprint*")) {
rsp.forward(Jenkins.getInstance().getFingerprint(Util.getDigestOf(baseFile.open())), "/", req);
InputStream fingerprintInput = baseFile.open();
try {
rsp.forward(Jenkins.getInstance().getFingerprint(Util.getDigestOf(fingerprintInput)), "/", req);
} finally {
fingerprintInput.close();
}
return;
}

Expand Down

3 comments on commit 2ea0276

@daniel-beck
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that should be in LTS?

@oleg-nenashev
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. The issue may overflow OpenedFiles if somebody starts browsing workspaces using a server with a very custom Java installation.

hudson.Util.getDigestOf() should close the stream in common cases. The risk appears if MessageDigest.getInstance("MD5") in hudson.Util.getDigestOf() throws an exception.

@oleg-nenashev
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the fact, we managed to catch it on a corrupted installation of HotSpot JVM

Please sign in to comment.