Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FIXED JENKINS-10346] thread-safety problem when computing fingerprints
- Loading branch information
Showing
3 changed files
with
58 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -509,11 +509,6 @@ public static String removeTrailingSlash(String s) { | |
else return s; | ||
} | ||
|
||
/** | ||
* Write-only buffer. | ||
*/ | ||
private static final byte[] garbage = new byte[8192]; | ||
|
||
/** | ||
* Computes MD5 digest of the given input stream. | ||
* | ||
|
@@ -528,7 +523,7 @@ public static String getDigestOf(InputStream source) throws IOException { | |
|
||
DigestInputStream in =new DigestInputStream(source,md5); | ||
try { | ||
while(in.read(garbage)>0) | ||
while(in.read(new byte[1024])>0) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kutzi
Author
Member
|
||
; // simply discard the input | ||
} finally { | ||
in.close(); | ||
|
@@ -708,7 +703,7 @@ public static String encode(String s) { | |
OutputStreamWriter w = new OutputStreamWriter(buf,"UTF-8"); | ||
|
||
for (int i = 0; i < s.length(); i++) { | ||
int c = (int) s.charAt(i); | ||
int c = s.charAt(i); | ||
if (c<128 && c!=' ') { | ||
out.append((char) c); | ||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is allocating a new byte array per iteration around the loop. It would be better as
byte buf = new byte[1024];
while (in.read(buf)>0)