jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1490313 - in /jena/trunk/jena-arq/src/main/java/org/apache/jena: atlas/lib/cache/CacheLRU.java riot/system/IRIResolver.java
Date Thu, 06 Jun 2013 14:56:30 GMT
Author: andy
Date: Thu Jun  6 14:56:30 2013
New Revision: 1490313

URL: http://svn.apache.org/r1490313
Log:
JENA-467 - Add synchronization to the use of global resolver when making a new "normal" resolver.

Modified:
    jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/lib/cache/CacheLRU.java
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/lib/cache/CacheLRU.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/lib/cache/CacheLRU.java?rev=1490313&r1=1490312&r2=1490313&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/lib/cache/CacheLRU.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/lib/cache/CacheLRU.java Thu Jun
 6 14:56:30 2013
@@ -22,10 +22,10 @@ import java.util.Iterator ;
 
 import org.apache.jena.atlas.lib.ActionKeyValue ;
 import org.apache.jena.atlas.lib.Cache ;
+import org.apache.jena.atlas.lib.CacheFactory ;
 
 
-
-/** This class is not thread-safe. Add a synchronization wrapper if needed (@link{CacheFcatory.createSync)}
 */
+/** This class is not thread-safe. Add a synchronization wrapper if needed ({@linkplain CacheFactory#createSync})
 */
 
 public class CacheLRU<K,V> implements Cache<K,V>
 {

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java?rev=1490313&r1=1490312&r2=1490313&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java Thu Jun
 6 14:56:30 2013
@@ -89,9 +89,15 @@ public abstract class IRIResolver
     /**
      * The current working directory, as a string.
      */
-    static private String globalBase = IRILib.filenameToIRI("./") ; // FileUtils.toURL(".").replace("/./",
"/") ;
+    static private String globalBase = IRILib.filenameToIRI("./") ;
+    
+    // The global resolver may be accessed by multiple threads
+    // but also some actions need consistency across more than one access
+    // so just sync'd access to  globalResolver is not enough, and we need
+    // a lock object.
     static private Object globalResolverLock = new Object() ;
-    private static IRIResolver globalResolver ; 
+    private static IRIResolver globalResolver ;
+    // Don't pass out - use the statics here.
     //public static IRIResolver get() { return globalResolver ; }
     
     /**
@@ -356,7 +362,9 @@ public abstract class IRIResolver
             if (baseS == null)
                 base = chooseBaseURI();
             else
-                base = globalResolver.resolveSilent(baseS) ;
+                synchronized(globalResolverLock) {
+                    base = globalResolver.resolveSilent(baseS) ;
+                }
         }
 
         public IRIResolverNormal(IRI baseIRI) {



Mime
View raw message