[ https://issues.apache.org/jira/browse/JENA-792?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gert van Valkenhoef updated JENA-792: ------------------------------------- Description: While unit testing an implementation of the DatasetGraph interface I ran in to this bug in DatasetGraphCollection: {code} @Test public void test() { DatasetGraph mem = DatasetGraphFactory.createMem(); DatasetGraph ds = DatasetGraphFactory.create(mem); ds.contains(NodeFactory.createURI("http://example.com/DoesNotExist"), NodeFactory.createURI("http://example.com/subject"), NodeFactory.createURI("http://example.com/predicate"), NodeFactory.createURI("http://example.com/object")); } {code} This throws: {code} java.lang.NullPointerException at com.hp.hpl.jena.sparql.core.DatasetGraphCollection.findInSpecificNamedGraph(DatasetGraphCollection.java:66) at com.hp.hpl.jena.sparql.core.DatasetGraphCollection.findInSpecificNamedGraph(DatasetGraphCollection.java:34) at com.hp.hpl.jena.sparql.core.DatasetGraphBaseFind.findNG(DatasetGraphBaseFind.java:59) at com.hp.hpl.jena.sparql.core.DatasetGraphBaseFind.find(DatasetGraphBaseFind.java:48) at com.hp.hpl.jena.sparql.core.DatasetGraphBase.contains(DatasetGraphBase.java:131) at ..... {code} It seems that the null check in findInSpecificNamedGraph is checking the wrong variable (it checks g == null but shoud check graph == null). was: While unit testing an implementation of the DatasetGraph interface I ran in to this bug in DatasetGraphCollection: @Test public void test() { DatasetGraph mem = DatasetGraphFactory.createMem(); DatasetGraph ds = DatasetGraphFactory.create(mem); ds.contains(NodeFactory.createURI("http://example.com/DoesNotExist"), NodeFactory.createURI("http://example.com/subject"), NodeFactory.createURI("http://example.com/predicate"), NodeFactory.createURI("http://example.com/object")); } This throws: java.lang.NullPointerException at com.hp.hpl.jena.sparql.core.DatasetGraphCollection.findInSpecificNamedGraph(DatasetGraphCollection.java:66) at com.hp.hpl.jena.sparql.core.DatasetGraphCollection.findInSpecificNamedGraph(DatasetGraphCollection.java:34) at com.hp.hpl.jena.sparql.core.DatasetGraphBaseFind.findNG(DatasetGraphBaseFind.java:59) at com.hp.hpl.jena.sparql.core.DatasetGraphBaseFind.find(DatasetGraphBaseFind.java:48) at com.hp.hpl.jena.sparql.core.DatasetGraphBase.contains(DatasetGraphBase.java:131) at ..... It seems that the null check in findInSpecificNamedGraph is checking the wrong variable (it checks g == null but shoud check graph == null). > DatasetGraphCollection throws NullPointerException when calling contains() > with non-existing graph > -------------------------------------------------------------------------------------------------- > > Key: JENA-792 > URL: https://issues.apache.org/jira/browse/JENA-792 > Project: Apache Jena > Issue Type: Bug > Components: Jena > Affects Versions: Jena 2.12.0 > Environment: Ubuntu 14.04 and Eclipse Luna. Jena, Fuseki, and JUnit > on the classpath. > Reporter: Gert van Valkenhoef > Labels: easyfix > > While unit testing an implementation of the DatasetGraph interface I ran in > to this bug in DatasetGraphCollection: > {code} > @Test public void test() { > DatasetGraph mem = DatasetGraphFactory.createMem(); > DatasetGraph ds = DatasetGraphFactory.create(mem); > ds.contains(NodeFactory.createURI("http://example.com/DoesNotExist"), > NodeFactory.createURI("http://example.com/subject"), > NodeFactory.createURI("http://example.com/predicate"), > NodeFactory.createURI("http://example.com/object")); > } > {code} > This throws: > {code} > java.lang.NullPointerException > at > com.hp.hpl.jena.sparql.core.DatasetGraphCollection.findInSpecificNamedGraph(DatasetGraphCollection.java:66) > at > com.hp.hpl.jena.sparql.core.DatasetGraphCollection.findInSpecificNamedGraph(DatasetGraphCollection.java:34) > at > com.hp.hpl.jena.sparql.core.DatasetGraphBaseFind.findNG(DatasetGraphBaseFind.java:59) > at > com.hp.hpl.jena.sparql.core.DatasetGraphBaseFind.find(DatasetGraphBaseFind.java:48) > at > com.hp.hpl.jena.sparql.core.DatasetGraphBase.contains(DatasetGraphBase.java:131) > at > ..... > {code} > It seems that the null check in findInSpecificNamedGraph is checking the > wrong variable (it checks g == null but shoud check graph == null). -- This message was sent by Atlassian JIRA (v6.3.4#6332)