asciidoctor / asciidoctorj

:coffee: Java bindings for Asciidoctor. Asciidoctor on the JVM!
http://asciidoctor.org
Apache License 2.0
623 stars 173 forks source link

(v2.5.x) Fixes #1158. Avoid concurrent initialization of Ruby wrapper class wh… #1173

Closed robertpanzer closed 1 year ago

robertpanzer commented 1 year ago

…en converting to stream.

Thank you for opening a pull request and contributing to AsciidoctorJ!

Please take a bit of time giving some details about your pull request:

Kind of change

Description

What is the goal of this pull request?

Fix the issue reported in https://github.com/asciidoctor/asciidoctorj/issues/1158. When converting to a stream a new RubyClass is created lazily. This step is not protected with a mutex, so that JRuby can fail. This PR wants to fix this so that this exception does not occur when converting documents in parallel with one Asciidoctor instance.

How does it achieve that?

Eagerly create the class when initializing the Asciidoctor instance.

Are there any alternative ways to implement this?

Yes, the class could be created lazily and a mutex could guarantee mutual exclusion so that the class is created only once.

Are there any implications of this pull request? Anything a user must know?

Issue

Fixes #1157

Release notes

Please add a corresponding entry to the file CHANGELOG.adoc