Skip to content

Commit

Permalink
GH-4705 Fix for potentially unclosed iteration in ExclusiveStatement (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad authored Jul 31, 2023
2 parents bc1ce6c + a6740d3 commit 48881cb
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public StatementSource getOwner() {
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(
BindingSet bindings) throws QueryEvaluationException {

CloseableIteration<BindingSet, QueryEvaluationException> res = null;

try {

Endpoint ownedEndpoint = queryInfo.getFederationContext()
Expand All @@ -64,7 +66,6 @@ public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(
* getStatements(subj, pred, obj) instead of evaluating a prepared query.
*/

CloseableIteration<BindingSet, QueryEvaluationException> res;
if (t.usePreparedQuery(this, queryInfo)) {

AtomicBoolean isEvaluated = new AtomicBoolean(false); // is filter evaluated
Expand Down Expand Up @@ -101,8 +102,15 @@ public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(

return res;

} catch (RepositoryException | MalformedQueryException e) {
throw new QueryEvaluationException(e);
} catch (Throwable t) {
if (res != null) {
res.close();
}
if (t instanceof RepositoryException || t instanceof MalformedQueryException) {
throw new QueryEvaluationException(t);
} else {
throw t;
}
}
}
}

0 comments on commit 48881cb

Please sign in to comment.