Skip to content

Commit

Permalink
[JENKINS-8856] Diagnostic improvement: show ‘'i' 'l' 'l' 'e' 'd' 0x0a…
Browse files Browse the repository at this point in the history
…’ rather than ‘696c6c65640a’, so it is more obviously the rest of ‘Killed’.
  • Loading branch information
jglick committed Jul 26, 2013
1 parent 2b84547 commit d0334ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/main/java/hudson/remoting/HexDump.java
Expand Up @@ -12,9 +12,17 @@ public static String toHex(byte[] buf) {
public static String toHex(byte[] buf, int start, int len) {
StringBuilder r = new StringBuilder(len*2);
for (int i=0; i<len; i++) {
if (i > 0) {
r.append(' ');
}
byte b = buf[start+i];
r.append(CODE.charAt((b>>4)&15));
r.append(CODE.charAt(b&15));
if (b >= 0x20 && b <= 0x7e) {
r.append('\'').append((char) b).append('\'');
} else {
r.append("0x");
r.append(CODE.charAt((b>>4)&15));
r.append(CODE.charAt(b&15));
}
}
return r.toString();
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/hudson/remoting/HexDumpTest.java
Expand Up @@ -7,6 +7,6 @@
*/
public class HexDumpTest extends TestCase {
public void test1() {
assertEquals("0001ff",HexDump.toHex(new byte[]{0,1,-1}));
assertEquals("0x00 0x01 0xff 'A'", HexDump.toHex(new byte[] {0, 1, -1, 65}));
}
}

0 comments on commit d0334ba

Please sign in to comment.