jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1342006 - in /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine: http/Service.java iterator/QueryIter.java main/iterator/QueryIterService.java
Date Wed, 23 May 2012 20:01:39 GMT
Author: andy
Date: Wed May 23 20:01:38 2012
New Revision: 1342006

URL: http://svn.apache.org/viewvc?rev=1342006&view=rev
Log:
JENA-248 Read all bytes after SERVICE request and close the connection.

Modified:
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/http/Service.java
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter.java
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/main/iterator/QueryIterService.java

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/http/Service.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/http/Service.java?rev=1342006&r1=1342005&r2=1342006&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/http/Service.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/http/Service.java Wed
May 23 20:01:38 2012
@@ -19,7 +19,9 @@
 package com.hp.hpl.jena.sparql.engine.http;
 
 import java.io.InputStream ;
-import java.util.Map;
+import java.util.Map ;
+
+import org.openjena.atlas.io.IO ;
 
 import com.hp.hpl.jena.query.Query ;
 import com.hp.hpl.jena.query.QueryExecException ;
@@ -31,6 +33,7 @@ import com.hp.hpl.jena.sparql.algebra.Op
 import com.hp.hpl.jena.sparql.algebra.op.OpService ;
 import com.hp.hpl.jena.sparql.engine.QueryIterator ;
 import com.hp.hpl.jena.sparql.engine.Rename ;
+import com.hp.hpl.jena.sparql.engine.iterator.QueryIter ;
 import com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorResultSet ;
 import com.hp.hpl.jena.sparql.mgt.Explain ;
 import com.hp.hpl.jena.sparql.util.Context ;
@@ -92,7 +95,6 @@ public class Service
         if ( ! op.getService().isURI() )
             throw new QueryExecException("Service URI not bound: "+op.getService()) ; 
         
-        
         // This relies on the observation that the query was originally correct,
         // so reversing the scope renaming is safe (it merely restores the algebra expression).
         // Any variables that reappear should be internal ones that were hidden by renaming
@@ -108,8 +110,16 @@ public class Service
         String uri = op.getService().getURI() ;
         HttpQuery httpQuery = configureQuery(uri, context, query);
         InputStream in = httpQuery.exec() ;
+
+        // Read the whole of the results now.
+        // Avoids the problems with calling back into the same system e.g. Fuseki+SERVICE
<http://localhost:3030/...>
+        
         ResultSet rs = ResultSetFactory.fromXML(in) ;
-        return new QueryIteratorResultSet(rs) ; 
+        QueryIterator qIter = new QueryIteratorResultSet(rs) ; 
+        qIter = QueryIter.materialize(qIter) ;
+        // And close connection now, not when qIter is closed. 
+        IO.close(in) ;
+        return  qIter ;
     }
     
     /**

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter.java?rev=1342006&r1=1342005&r2=1342006&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter.java
(original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter.java
Wed May 23 20:01:38 2012
@@ -50,9 +50,13 @@ public abstract class QueryIter extends 
 
     public static QueryIter materialize(QueryIterator qIter, ExecutionContext execCxt)
     {
-        return makeTracked(new QueryIteratorCopy(qIter), execCxt) ;
+        return makeTracked(materialize(qIter), execCxt) ;
     }
 
+    public static QueryIterator materialize(QueryIterator qIter)
+    {
+        return new QueryIteratorCopy(qIter) ;
+    }
     
     @Override
     public final void close()

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/main/iterator/QueryIterService.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/main/iterator/QueryIterService.java?rev=1342006&r1=1342005&r2=1342006&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/main/iterator/QueryIterService.java
(original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/main/iterator/QueryIterService.java
Wed May 23 20:01:38 2012
@@ -49,10 +49,11 @@ public class QueryIterService extends Qu
         QueryIterator qIter ;
         try {
             qIter = Service.exec((OpService)op, getExecContext().getContext()) ;
-            // Materialise, otherwise we may have outstanding incoming data.
-            // Allows the server to fulfil the request as soon as possible.
+            // This iterator is materialized already otherwise we may end up
+            // not servicing the HTTP connection as needed.
             // In extremis, can cause a deadlock when SERVICE loops back to this server.
-            qIter = QueryIter.materialize(qIter, getExecContext()) ;
+            // Add tracking.
+            qIter = QueryIter.makeTracked(qIter, getExecContext()) ;
         } catch (RuntimeException ex)
         {
             if ( silent )



Mime
View raw message