apache / jena

Apache Jena
https://jena.apache.org/
Apache License 2.0
1.12k stars 652 forks source link

GH-2787: Deadlock in JenaSystem.init() #2792

Closed arne-bdt closed 1 month ago

arne-bdt commented 1 month ago

Added a fail-fast mechanism: now throwing an ExceptionInInitializerError when a thread attempts to enter JenaSystem.init() while another thread is in the initialization process.

Refactored JenaSystem.init() using the "Initialization-on-demand holder idiom" for simpler and safer initialization.

Additionally, I have added integration tests for JenaSystem.init(), including the parallel execution scenario from the issue, to ensure coverage of potential concurrency issues.

GitHub issue resolved #2787


By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the Contributor's Agreement.


See the Apache Jena "Contributing" guide.

afs commented 1 month ago

I'm unsure about this PR,

I set this PR to "draft" - hope you don't mind.

arne-bdt commented 1 month ago

I found another "solution": Added a fail-fast mechanism: now throwing an ExceptionInInitializerError when a thread attempts to enter JenaSystem.init() while another thread is in the initialization process.

What do you think?

afs commented 1 month ago

I think requiring single threaded initialization will break existing usage. Until we agree that it is the only option, I don't think we should go that way.

Discussion on the issue.

arne-bdt commented 1 month ago

see https://github.com/apache/jena/issues/2787#issuecomment-2435110319