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 2012/10/21 16:53:41 UTC

svn commit: r1400662 - /jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/compose/MultiUnion.java

Author: andy
Date: Sun Oct 21 14:53:41 2012
New Revision: 1400662

URL: http://svn.apache.org/viewvc?rev=1400662&view=rev
Log:
JENA-315 : Close iterators when throwables happen.

Modified:
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/compose/MultiUnion.java

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/compose/MultiUnion.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/compose/MultiUnion.java?rev=1400662&r1=1400661&r2=1400662&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/compose/MultiUnion.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/compose/MultiUnion.java Sun Oct 21 14:53:41 2012
@@ -20,9 +20,6 @@
 ///////////////
 package com.hp.hpl.jena.graph.compose;
 
-
-// Imports
-///////////////
 import com.hp.hpl.jena.JenaRuntime;
 import com.hp.hpl.jena.graph.*;
 import com.hp.hpl.jena.graph.impl.SimpleEventManager;
@@ -33,7 +30,6 @@ import com.hp.hpl.jena.util.iterator.*;
 
 import java.util.*;
 
-
 /**
  * <p>
  * A graph implementation that presents the union of zero or more subgraphs,
@@ -85,9 +81,6 @@ public class MultiUnion extends Polyadic
     
     private boolean optimising = JenaRuntime.getSystemProperty( "jena.union.optimise", "yes" ).equals( "yes" );
     
-    // External signature methods
-    //////////////////////////////////
-
     /**
         Unions share the reifiers of their base graphs. THIS WILL CHANGE.
     */
@@ -171,19 +164,25 @@ public class MultiUnion extends Polyadic
 
 
     /**
-     	Answer the concatenation of all the iterators from a-subGraph.find( t ).
-    */
-    private ExtendedIterator<Triple> multiGraphFind( final TripleMatch t )
-        {
-        Set<Triple> seen = CollectionFactory.createHashedSet();
-        ExtendedIterator<Triple> result = NullIterator.instance();
-        for (Iterator<Graph> graphs = m_subGraphs.iterator(); graphs.hasNext(); ) 
-            {
-            ExtendedIterator<Triple> newTriples = recording( rejecting( graphs.next().find( t ), seen ), seen );
-            result = result.andThen( newTriples );
+     * Answer the concatenation of all the iterators from a-subGraph.find( t ).
+     */
+    private ExtendedIterator<Triple> multiGraphFind(final TripleMatch t)
+    {
+        Set<Triple> seen = CollectionFactory.createHashedSet() ;
+        ExtendedIterator<Triple> result = NullIterator.instance() ;
+        boolean finished = false ;
+        try {
+            for (Iterator<Graph> graphs = m_subGraphs.iterator(); graphs.hasNext();) {
+                ExtendedIterator<Triple> newTriples = recording(rejecting(graphs.next().find(t), seen), seen) ;
+                result = result.andThen(newTriples) ;
             }
-        return result;
+            finished = true ;
+            return result ;
+        } finally { // Throwable happened.
+            if (!finished)
+                result.close() ;
         }
+    }
 
     /**
      * <p>