adding close to Asciidoctor to avoid to leak when creating an asciidoctor instance
MODIFY
asciidoctorj-api/src/main/java/org/asciidoctor/Asciidoctor.java
asciidoctorj-api/src/main/java/org/asciidoctor/Asciidoctor.java
@@ -24,7 +24,7 @@ import java.util.stream.Collectors;
/**
* @author lordofthejars
*/
-public interface Asciidoctor {
+public interface Asciidoctor extends AutoCloseable {
String STRUCTURE_MAX_LEVEL = "STRUCTURE_MAX_LEVEL";
@@ -531,4 +531,8 @@ public interface Asciidoctor {
throw new IllegalArgumentException("Cannot unwrap to " + clazz.getName());
}
+ @Override
+ default void close() {
+ // no-op
+ }
}

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JRubyAsciidoctor.java
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JRubyAsciidoctor.java
@@ -45,8 +45,6 @@ public class JRubyAsciidoctor implements AsciidoctorJRuby, LogHandler {
private List<LogHandler> logHandlers = new ArrayList<>();
- private final static Logger LOGGER = Logger.getLogger("asciidoctorj");
-
public JRubyAsciidoctor() {
this(createRubyRuntime(Collections.singletonMap(GEM_PATH, null), new ArrayList<>(), null));
processRegistrations(this);
@@ -140,6 +138,13 @@ public class JRubyAsciidoctor implements AsciidoctorJRuby, LogHandler {
return new RubyInstanceConfig();
}
+ @Override
+ public void close() {
+ if (rubyRuntime != null) {
+ rubyRuntime.tearDown();
+ }
+ }
+
@Override
public void registerLogHandler(final LogHandler logHandler) {
if (!this.logHandlers.contains(logHandler)) {

adding close to Asciidoctor to avoid to leak when creating an asciidoctor instance