Skip to content

Commit 8ffccdf

Browse files
authored
GH-4867 change from Exception to Throwable so that we can also log StackOverflowError and which shape caused it (#4909)
2 parents 2306c8b + a328662 commit 8ffccdf

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static ValidationReport validate(Sail dataRepo, Sail shapesRepo) {
7777

7878
}
7979
shapesConnection.commit();
80-
} catch (Exception e) {
80+
} catch (Throwable e) {
8181
logger.warn("Failed to read shapes", e);
8282
throw e;
8383
}
@@ -98,7 +98,7 @@ public static ValidationReport validate(Sail dataRepo, Sail shapesRepo) {
9898
return performValidation(shapes, new ConnectionsGroup(verySimpleRdfsBackwardsChainingConnection, null,
9999
null, null, new Stats(), () -> reasoner,
100100
new ShaclSailConnection.Settings(true, true, true, IsolationLevels.NONE), true));
101-
} catch (Exception e) {
101+
} catch (Throwable e) {
102102
logger.warn("Failed to validate shapes", e);
103103
throw e;
104104
}

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShapeValidationContainer.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ public ShapeValidationContainer(Shape shape, Supplier<PlanNode> planNodeSupplier
5353
} else {
5454
this.planNode = planNode;
5555
}
56-
} catch (Exception e) {
56+
} catch (Throwable e) {
57+
logger.warn("Error processing SHACL Shape {}", shape.getId(), e);
58+
logger.warn("Error processing SHACL Shape\n{}", shape, e);
59+
if (e instanceof Error) {
60+
throw e;
61+
}
5762
throw new SailException("Error processing SHACL Shape " + shape.getId() + "\n" + shape, e);
5863
}
5964

@@ -76,8 +81,12 @@ public ValidationResultIterator performValidation() {
7681
try (CloseableIteration<? extends ValidationTuple, SailException> iterator = planNode.iterator()) {
7782
validationResults = new ValidationResultIterator(iterator, effectiveValidationResultsLimitPerConstraint);
7883
return validationResults;
79-
} catch (Exception e) {
84+
} catch (Throwable e) {
8085
logger.warn("Error validating SHACL Shape {}", shape.getId(), e);
86+
logger.warn("Error validating SHACL Shape\n{}", shape, e);
87+
if (e instanceof Error) {
88+
throw e;
89+
}
8190
throw new SailException("Error validating SHACL Shape " + shape.getId() + "\n" + shape, e);
8291
} finally {
8392
handlePostLogging(before, validationResults);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,9 @@ public PlanNode generatePlans(ConnectionsGroup connectionsGroup, ValidationSetti
450450
} else {
451451
throw new ShaclUnsupportedException("Unknown validation approach: " + validationApproach);
452452
}
453-
} catch (RuntimeException e) {
453+
} catch (Throwable e) {
454454
logger.warn("Error processing SHACL Shape {}", id, e);
455+
logger.warn("Error processing SHACL Shape\n{}", this, e);
455456
throw new SailException("Error processing SHACL Shape " + id + "\n" + this, e);
456457
}
457458

@@ -707,7 +708,7 @@ public static List<ContextWithShape> getShapesInContext(ShapeSource shapeSource,
707708
.map(r -> {
708709
try {
709710
return new ShaclProperties(r, shapeSourceWithContext);
710-
} catch (Exception e) {
711+
} catch (Throwable e) {
711712
logger.warn("Error parsing shape {}", r, e);
712713
throw new ShaclShapeParsingException(e, r);
713714
}
@@ -720,7 +721,7 @@ public static List<ContextWithShape> getShapesInContext(ShapeSource shapeSource,
720721
return PropertyShape.getInstance(p, shapeSourceWithContext, parseSettings, cache);
721722
}
722723
throw new ShaclShapeParsingException("Unknown shape type", p.getId());
723-
} catch (Exception e) {
724+
} catch (Throwable e) {
724725
logger.warn("Error parsing shape {}", p.getId(), e);
725726
if (e instanceof ShaclShapeParsingException) {
726727
throw e;
@@ -746,6 +747,7 @@ public String toString() {
746747
statements.setNamespace(RSX.NS);
747748
statements.setNamespace(RDFS.NS);
748749
statements.setNamespace(RDF.NS);
750+
statements.setNamespace(DASH.NS);
749751
WriterConfig writerConfig = new WriterConfig()
750752
.set(BasicWriterSettings.PRETTY_PRINT, true)
751753
.set(BasicWriterSettings.INLINE_BLANK_NODES, true);

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/results/lazy/LazyValidationReport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private void evaluateLazyAspect() {
8181
validationResultIterators = null;
8282

8383
}
84-
} catch (Exception e) {
84+
} catch (Throwable e) {
8585
logger.warn("Error evaluating lazy validation report", e);
8686
throw e;
8787
}
@@ -104,7 +104,7 @@ public Model asModel(Model model) {
104104
}
105105

106106
return model;
107-
} catch (Exception e) {
107+
} catch (Throwable e) {
108108
logger.warn("Error converting validation report to model", e);
109109
throw e;
110110
}

0 commit comments

Comments
 (0)