diff --git a/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/log/internal/JavaLogger.java b/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/log/internal/JavaLogger.java index 22394669f..0c812b7fa 100644 --- a/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/log/internal/JavaLogger.java +++ b/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/log/internal/JavaLogger.java @@ -19,6 +19,7 @@ import org.jruby.runtime.builtin.IRubyObject; import java.util.Objects; +import java.util.Optional; public class JavaLogger extends RubyObject { @@ -94,10 +95,12 @@ private LogRecord createLogRecord(final ThreadContext threadContext, final Severity severity, final Cursor cursor, final String message) { - BacktraceElement[] backtrace = threadContext.getBacktrace(); - final String sourceFileName = backtrace[2].getFilename(); - final String sourceMethodName = backtrace[2].getMethod(); - final LogRecord record = new LogRecord(severity, cursor, message, sourceFileName, sourceMethodName); + final Optional elem = threadContext.getBacktrace(0) + .skip(1) + .findFirst(); + + final String sourceFileName = elem.map(BacktraceElement::getFilename).orElse(null); + final String sourceMethodName = elem.map(BacktraceElement::getMethod).orElse(null); final LogRecord record = new LogRecord(severity, cursor, message, sourceFileName, sourceMethodName); return record; } diff --git a/build.gradle b/build.gradle index 3de206c60..285b73baf 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ ext { guavaVersion = '18.0' hamcrestVersion = '1.3' jcommanderVersion = '1.35' - jrubyVersion = '9.2.5.0' + jrubyVersion = '9.2.6.0' jsoupVersion = '1.10.2' junitVersion = '4.12' nettyVersion = '4.0.33.Final'