@Test public void calculateFingerprint_shouldGenerateTheSameFingerprint_givenTwoIdenticalThrowables() throws Exception { String exceptionMessage = "message"; Throwable firstException = new RuntimeException(exceptionMessage); Throwable secondException = new RuntimeException(exceptionMessage); firstException.setStackTrace(constructCustomStackTrace()); secondException.setStackTrace(constructCustomStackTrace()); String firstFingerprint = calculator.calculateFingerprint(firstException); String secondFingerprint = calculator.calculateFingerprint(secondException); assertEquals(firstFingerprint, secondFingerprint); }
public String calculateFingerprint(Throwable t) { MessageDigest md5 = getMD5Instance(); PrintStream ps = new PrintStream(new DigestOutputStream(new DoNothingOutputStream(), md5)); t.printStackTrace(ps); return base64Encoder.encodeToString(md5.digest()); }
ThrowableFingerprintCalculator { public String calculateFingerprint(Throwable t) { MessageDigest md5 = getMD5Instance(); PrintStream ps = new PrintStream(new DigestOutputStream(new DoNothingOutputStream(), md5)); t.printStackTrace(ps); return base64Encoder.encodeToString(md5.digest()); } }
ThrowableFingerprintCalculator { public String calculateFingerprint(Throwable t) { MessageDigest md5 = getMD5Instance(); PrintStream ps = new PrintStream(new DigestOutputStream(new DoNothingOutputStream(), md5)); t.printStackTrace(ps); return base64Encoder.encodeToString(md5.digest()); }  }
ThrowableFingerprintCalculator { public String calculateFingerprint(Throwable t) { MessageDigest md5 = getMD5Instance(); PrintStream ps = new PrintStream(new DigestOutputStream(new DoNothingOutputStream(), md5)); t.printStackTrace(ps); return base64Encoder.encodeToString(md5.digest()); }  String calculateFingerprint(Throwable t); }
ThrowableFingerprintCalculator { public String calculateFingerprint(Throwable t) { MessageDigest md5 = getMD5Instance(); PrintStream ps = new PrintStream(new DigestOutputStream(new DoNothingOutputStream(), md5)); t.printStackTrace(ps); return base64Encoder.encodeToString(md5.digest()); }  String calculateFingerprint(Throwable t);  }