This is an automated email from the ASF dual-hosted git repository.

andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git


The following commit(s) were added to refs/heads/main by this push:
     new 87957a52a0 JENA-2356: Fix race in QueryEngineRegistry, 
UpdateEngineRegistry init
     new 9bb24d2a5d Merge pull request #2047 from shawnsmith/factory-init
87957a52a0 is described below

commit 87957a52a046abcff5ce447f035a6b63b9eba366
Author: Shawn Smith <shawn.smith@data.world>
AuthorDate: Wed Oct 18 13:32:40 2023 -0500

    JENA-2356: Fix race in QueryEngineRegistry, UpdateEngineRegistry init
---
 .../java/org/apache/jena/sparql/engine/QueryEngineRegistry.java  | 9 ++++-----
 .../java/org/apache/jena/sparql/modify/UpdateEngineRegistry.java | 9 ++++-----
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryEngineRegistry.java 
b/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryEngineRegistry.java
index 9969b6f619..0572035098 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryEngineRegistry.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryEngineRegistry.java
@@ -32,14 +32,13 @@ import org.apache.jena.sparql.util.Context;
 public class QueryEngineRegistry
 {
     List<QueryEngineFactory> factories = new ArrayList<>();
-    static { init(); }
 
     // Singleton
-    static QueryEngineRegistry registry = null;
+    private static QueryEngineRegistry registry;
+    static { init(); }
+
     static public QueryEngineRegistry get()
     {
-        if ( registry == null )
-            init();
         return registry;
     }
 
@@ -86,7 +85,7 @@ public class QueryEngineRegistry
 
     public QueryEngineRegistry() { }
 
-    private static synchronized void init()
+    private static void init()
     {
         registry = new QueryEngineRegistry();
         registry.add(QueryEngineMain.getFactory());
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateEngineRegistry.java
 
b/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateEngineRegistry.java
index 6ad8a682bc..d45eef55f3 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateEngineRegistry.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateEngineRegistry.java
@@ -27,20 +27,19 @@ import org.apache.jena.sparql.util.Context ;
 public class UpdateEngineRegistry
 {
     List<UpdateEngineFactory> factories = new ArrayList<>() ;
-    static { init() ; }
 
     // Singleton
-    static UpdateEngineRegistry registry = null ;
+    private static UpdateEngineRegistry registry ;
+    static { init() ; }
+
     static public UpdateEngineRegistry get()
     {
-        if ( registry == null )
-            init() ;
         return registry;
     }
 
     private UpdateEngineRegistry() { }
 
-    private static synchronized void init()
+    private static void init()
     {
         registry = new UpdateEngineRegistry() ;
         registry.add(UpdateEngineMain.getFactory()) ;

Reply via email to