commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [1/3] incubator-commonsrdf git commit: rdf4j close getGraphNames() within stream
Date Fri, 04 Nov 2016 00:56:30 GMT
Repository: incubator-commonsrdf
Updated Branches:
  refs/heads/master 99279a135 -> 30dda0825


rdf4j close getGraphNames() within stream


Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/16c585c4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/16c585c4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/16c585c4

Branch: refs/heads/master
Commit: 16c585c44672be9e742abfcb2174a11421b55ed5
Parents: 99279a1
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Fri Nov 4 00:55:24 2016 +0000
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Fri Nov 4 00:55:24 2016 +0000

----------------------------------------------------------------------
 .../commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java   | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/16c585c4/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
index 8c266a9..1d30769 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
@@ -215,14 +215,10 @@ class RepositoryDatasetImpl extends AbstractRepositoryGraphLike<Quad>
implements
 
     @Override
     public Stream<BlankNodeOrIRI> getGraphNames() {
-        // FIXME: Will the below close the connection before the stream has been
-        // consumed outside?
-        try (RepositoryConnection conn = getRepositoryConnection()) {
-            RepositoryResult<Resource> contexts = conn.getContextIDs();
-            // NOTE: connection will be closed outside by the
-            // Iterations.stream()
-            return Iterations.stream(contexts).map(g -> (BlankNodeOrIRI) rdf4jTermFactory.asRDFTerm(g));
-        }
+       RepositoryConnection conn = getRepositoryConnection();
+       RepositoryResult<Resource> contexts = conn.getContextIDs();
+        return Iterations.stream(contexts).map(g -> (BlankNodeOrIRI) rdf4jTermFactory.asRDFTerm(g))
+                .onClose(conn::close);
     }
 
 }


Mime
View raw message