commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [3/3] incubator-commonsrdf git commit: Avoid NPE if Dataset.contains(null, null, null, null)
Date Thu, 03 Nov 2016 14:14:58 GMT
Avoid NPE if Dataset.contains(null, null, null, null)


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

Branch: refs/heads/master
Commit: 1b7b2ecaa8349e5e439ebae0abf136c36041e4ad
Parents: 9f20482
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Thu Nov 3 14:13:48 2016 +0000
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Thu Nov 3 14:13:48 2016 +0000

----------------------------------------------------------------------
 .../main/java/org/apache/commons/rdf/simple/DatasetImpl.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/1b7b2eca/simple/src/main/java/org/apache/commons/rdf/simple/DatasetImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/DatasetImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/DatasetImpl.java
index 974122d..9182178 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/DatasetImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/DatasetImpl.java
@@ -129,7 +129,13 @@ final class DatasetImpl implements Dataset {
     @Override
     public Stream<Quad> stream(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI
subject, IRI predicate,
             RDFTerm object) {
-        final Optional<BlankNodeOrIRI> newGraphName = graphName.map(g -> (BlankNodeOrIRI)
internallyMap(g));
+        final Optional<BlankNodeOrIRI> newGraphName;
+        if (graphName == null) { 
+            // Avoid Optional<Optional<BlankNodeOrIRI>> ...
+            newGraphName = null;
+        } else {
+            newGraphName = graphName.map(g -> (BlankNodeOrIRI) internallyMap(g));
+        }
         final BlankNodeOrIRI newSubject = (BlankNodeOrIRI) internallyMap(subject);
         final IRI newPredicate = (IRI) internallyMap(predicate);
         final RDFTerm newObject = internallyMap(object);


Mime
View raw message