Skip to content

Commit

Permalink
0003524: Indicate when the JVM has optimized a stack in the log
Browse files Browse the repository at this point in the history
  • Loading branch information
mmichalek committed Apr 20, 2018
1 parent cc6c5e1 commit 293b673
Showing 1 changed file with 16 additions and 3 deletions.
Expand Up @@ -23,6 +23,7 @@
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -96,14 +97,26 @@ protected String toKey(LoggingEvent event) {
}

try {
CRC32 crc = new CRC32();
crc.update(ArrayUtils.toString(event.getThrowableStrRep()).getBytes("UTF8"));
return event.getThrowableInformation().getThrowable().getClass().getSimpleName() + ":" + crc.getValue();
StringBuilder buff = new StringBuilder(128);
Throwable throwable = event.getThrowableInformation().getThrowable();
buff.append(throwable.getClass().getSimpleName());
if (throwable.getStackTrace().length == 0) {
buff.append("-jvm-optimized");
}
buff.append(":");
buff.append(getThrowableHash(event.getThrowableStrRep()));
return buff.toString();
} catch (Exception ex) {
LogLog.error("Failed to hash stack trace.", ex);
return null;
}
}

protected long getThrowableHash(String[] throwableString) throws UnsupportedEncodingException {
CRC32 crc = new CRC32();
crc.update(ArrayUtils.toString(throwableString).getBytes("UTF8"));
return crc.getValue();
}

protected LoggingEvent appendKey(LoggingEvent event, String key) {
String message = getMessageWithKey(event, key, ".init");
Expand Down

0 comments on commit 293b673

Please sign in to comment.