Permalink
Browse files

fix Logging test for tails=true build

In the tails=true build, the calling method cannot always be
determined due to stack frames being optimized away, so we must be
prepared for LogRecord.getSourceMethodName to return null.
  • Loading branch information...
dicej committed Aug 6, 2011
1 parent 792653e commit 5dbcbb825bfef46d671cbb3c541bfed735d39e8d
Showing with 6 additions and 2 deletions.
  1. +6 −2 test/Logging.java
View
@@ -49,8 +49,12 @@ public void publish(LogRecord r) {
StringBuilder sb = new StringBuilder();
sb.append(r.getLoggerName());
indent(sb, NAME_WIDTH - r.getLoggerName().length());
- sb.append(r.getSourceMethodName());
- indent(sb, METHOD_WIDTH - r.getSourceMethodName().length());
+ String methodName = r.getSourceMethodName();
+ if (methodName == null) {
+ methodName = "<unknown>";
+ }
+ sb.append(methodName);
+ indent(sb, METHOD_WIDTH - methodName.length());
sb.append(r.getLevel().getName());
indent(sb, LEVEL_WIDTH - r.getLevel().getName().length());
sb.append(r.getMessage());

0 comments on commit 5dbcbb8

Please sign in to comment.