You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2013/08/29 20:10:01 UTC

svn commit: r1518742 - /jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java

Author: andy
Date: Thu Aug 29 18:10:01 2013
New Revision: 1518742

URL: http://svn.apache.org/r1518742
Log:
Cautiously decide whether to use transactions
and cope without printing a stacktrace even
with the wrong decision.

Modified:
    jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java

Modified: jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java?rev=1518742&r1=1518741&r2=1518742&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java (original)
+++ jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java Thu Aug 29 18:10:01 2013
@@ -38,6 +38,7 @@ import com.hp.hpl.jena.query.ReadWrite ;
 import com.hp.hpl.jena.sparql.SystemARQ ;
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;
 import com.hp.hpl.jena.sparql.core.DatasetGraphWithLock ;
+import com.hp.hpl.jena.sparql.core.DatasetGraphWrapper ;
 import com.hp.hpl.jena.sparql.core.Transactional ;
 
 public class HttpAction
@@ -87,23 +88,26 @@ public class HttpAction
     public void setDataset(DatasetRef desc) {
         this.dsRef = desc ;
         this.dsg = desc.dataset ;
-
-        if ( dsg instanceof DatasetGraphWithLock ) {
-            transactional = (Transactional)dsg ;
-            isTransactional = false ;       // No real abort.
-        } else if ( dsg instanceof Transactional ) {
+        
+        if ( dsg instanceof Transactional ) {
             transactional = (Transactional)dsg ;
-            isTransactional = true ;
+            DatasetGraph basedsg = unwrap(dsg) ;
+            // Use transactional if it looks safe - abort is necessary.
+            isTransactional = ( basedsg instanceof Transactional ) ;
         } else {
-            // Non-transactional - wrap in something that does locking to give
-            // the same functionality in the absense of errors, with less concurrency.
-            DatasetGraphWithLock dsglock = new DatasetGraphWithLock(dsg) ;
-            transactional = dsglock ;
+            transactional = new DatasetGraphWithLock(dsg) ; 
+            // No real abort.
             isTransactional = false ;
-            dsg = dsglock ;
         }
     }
     
+    private DatasetGraph unwrap(DatasetGraph dsg) {
+        while ( dsg instanceof DatasetGraphWrapper ) {
+            dsg = ((DatasetGraphWrapper)dsg).getWrapped() ;
+        }
+        return dsg ;
+    }
+        
     public void setService(ServiceRef srvRef) {
         this.srvRef = srvRef ; 
     }
@@ -142,7 +146,12 @@ public class HttpAction
     }
 
     public void abort() {
-        transactional.abort() ;
+        try { transactional.abort() ; } 
+        catch (Exception ex) {
+            // Some datasets claim to be transactional.
+            // We try to continue operation
+            Log.warn(this, "Exception during abort (operation attempts to continue): "+ex.getMessage()) ; 
+        }
         activeDSG = null ;
     }