Fix NPE when a document contains an empty table
Fixes
MODIFY
CHANGELOG.adoc
CHANGELOG.adoc
@@ -13,6 +13,10 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
== Unreleased
+Bug Fixes::
+
+ * Fix NullPointerException when a document contains an empty table with PDF backend (#944)
+
== 2.4.0 (2020-07-19)
Improvement::

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/log/internal/JavaLogger.java
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/log/internal/JavaLogger.java
@@ -205,8 +205,10 @@ public class JavaLogger extends RubyObject {
if (getRuntime().getHash().equals(msg.getType())) {
final RubyHash hash = (RubyHash) msg;
final Object sourceLocation = hash.get(getRuntime().newSymbol(LOG_PROPERTY_SOURCE_LOCATION));
+ if (sourceLocation != null) {
return new CursorImpl((IRubyObject) sourceLocation);
}
+ }
return null;
}
}
\ No newline at end of file

MODIFY
asciidoctorj-distribution/src/test/java/org/asciidoctor/WhenBackendIsPdf.java
asciidoctorj-distribution/src/test/java/org/asciidoctor/WhenBackendIsPdf.java
@@ -83,4 +83,13 @@ public class WhenBackendIsPdf {
outputFile1.delete();
}
+ @Test
+ public void pdf_should_not_fail_with_empty_tables() {
+ String filename = "empty-table";
+ File inputFile = this.classpath.getResource(filename + ".adoc");
+ File outputFile1 = new File(inputFile.getParentFile(), filename + ".pdf");
+
+ asciidoctor.convertFile(inputFile, options().backend("pdf").safe(SafeMode.SAFE).get());
+ assertThat(outputFile1.exists(), is(true));
+ }
}

ADD
asciidoctorj-distribution/src/test/resources/empty-table.adoc
+=== Empty table
+
+[cols="2s,3", grid="none", frame="none"]
+|===
+|===

Fix NPE when a document contains an empty table

Fixes #944.