Skip to content

Commit a3292ba

Browse files
authored
GH-4993 check if null before using the removedStatementTarget (#4994)
2 parents 4626eec + e6b2ab1 commit a3292ba

8 files changed

Lines changed: 79 additions & 3 deletions

File tree

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/targets/RSXTargetShape.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ private PlanNode getAddedRemovedInner(ConnectionsGroup connectionsGroup, Resourc
9292
dataGraph,
9393
statementMatchers,
9494
statementMatchers,
95-
null, sparqlFragment,
95+
null,
96+
sparqlFragment,
9697
vars,
9798
scope,
9899
false), false);

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/targets/TargetChainRetriever.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public void calculateNextStatementMatcher() {
204204
this.currentVarNames = currentStatementMatcher.getVarNames(varNames, removedStatement,
205205
varNamesInQueryFragment);
206206

207-
assert !currentVarNames.isEmpty();
207+
assert !currentVarNames.isEmpty() : "currentVarNames is empty!";
208208

209209
statements = connection.getStatements(
210210
currentStatementMatcher.getSubjectValue(),
@@ -289,7 +289,7 @@ private List<BindingSet> readStatementsInBulk(Set<String> varNames) {
289289
Statement next = statements.next();
290290
Stream<EffectiveTarget.StatementsAndMatcher> rootStatements = Stream
291291
.of(new EffectiveTarget.StatementsAndMatcher(List.of(next), currentStatementMatcher));
292-
if (removedStatement) {
292+
if (removedStatement && removedStatementTarget != null) {
293293
Stream<EffectiveTarget.StatementsAndMatcher> root = removedStatementTarget.getRoot(
294294
connectionsGroup,
295295
dataGraph, currentStatementMatcher,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
PREFIX ex: <http://example.com/ns#>
2+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
3+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
4+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
5+
PREFIX sh: <http://www.w3.org/ns/shacl#>
6+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
7+
8+
INSERT DATA {
9+
ex:validPerson1 a ex:Person ;
10+
rdfs:label "Jennifer";
11+
ex:knows ex:peter.
12+
13+
ex:peter a ex:Person.
14+
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PREFIX ex: <http://example.com/ns#>
2+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
3+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
4+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
5+
PREFIX sh: <http://www.w3.org/ns/shacl#>
6+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
7+
8+
DELETE DATA {
9+
ex:validPerson1 a ex:Person .
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@prefix ex: <http://example.com/ns#> .
2+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
3+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
4+
@prefix sh: <http://www.w3.org/ns/shacl#> .
5+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
6+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix rsx: <http://rdf4j.org/shacl-extensions#> .
8+
@prefix rdf4j: <http://rdf4j.org/schema/rdf4j#> .
9+
10+
[] a sh:ValidationReport;
11+
rdf4j:truncated false;
12+
sh:conforms true .
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
PREFIX ex: <http://example.com/ns#>
2+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
3+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
4+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
5+
PREFIX sh: <http://www.w3.org/ns/shacl#>
6+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
7+
8+
INSERT DATA {
9+
ex:validPerson1 a ex:Person ;
10+
rdfs:label "Jennifer";
11+
ex:knows ex:peter.
12+
13+
ex:peter a ex:Person.
14+
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
PREFIX ex: <http://example.com/ns#>
2+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
3+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
4+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
5+
PREFIX sh: <http://www.w3.org/ns/shacl#>
6+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
7+
8+
DELETE DATA {
9+
ex:validPerson1 rdfs:label "Jennifer" .
10+
ex:peter a ex:Person.
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@prefix ex: <http://example.com/ns#> .
2+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
3+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
4+
@prefix sh: <http://www.w3.org/ns/shacl#> .
5+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
6+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix rsx: <http://rdf4j.org/shacl-extensions#> .
8+
@prefix rdf4j: <http://rdf4j.org/schema/rdf4j#> .
9+
10+
[] a sh:ValidationReport;
11+
rdf4j:truncated false;
12+
sh:conforms true .

0 commit comments

Comments
 (0)