[
https://issues.apache.org/jira/browse/JENA-2151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17402462#comment-17402462
]
Holger Knublauch commented on JENA-2151:
----------------------------------------
Here is a stack trace from where it reaches the Iter.filter function
{noformat}
Thread [qtp947882-131] (Suspended (breakpoint at line 238 in Iter))
Iter<T>.filter(Iterator<? extends T>, Predicate<T>) line: 238
Iter<T>.removeNulls(Iterator<T>) line: 404
StageMatchTriple.accessTriple(Binding, Graph, Triple, Predicate<Triple>,
ExecutionContext) line: 63
StageMatchTriple.lambda$accessTriple$0(Graph, Triple, Predicate,
ExecutionContext, Binding) line: 48
1513195333.apply(Object) line: not available
IteratorFlatMap<IN,OUT>.hasNext() line: 57
IterAbortable<T>.hasNext() line: 49
QueryIterAbortable(QueryIterPlainWrapper).hasNextBinding() line: 60
QueryIterAbortable(QueryIteratorBase).hasNext() line: 114
QueryIterAssign(QueryIterProcessBinding).hasNextBinding() line: 66
QueryIterAssign(QueryIteratorBase).hasNext() line: 114
QueryIterConcat.hasNextBinding() line: 82
QueryIterConcat(QueryIteratorBase).hasNext() line: 114
QueryIterUnion(QueryIterRepeatApply).hasNextBinding() line: 69
QueryIterUnion(QueryIteratorBase).hasNext() line: 114
QueryIterProject(QueryIterConvert).hasNextBinding() line: 58
QueryIterProject(QueryIteratorBase).hasNext() line: 114
QueryIteratorCheck(QueryIteratorWrapper).hasNextBinding() line: 38
QueryIteratorCheck(QueryIteratorBase).hasNext() line: 114
QueryIteratorCloseable(QueryIteratorWrapper).hasNextBinding() line: 38
QueryIteratorCloseable(QueryIteratorBase).hasNext() line: 114
ResultSetStream.hasNext() line: 64
ResultSetCheckCondition.hasNext() line: 55
SHACLSPARQLARQFunction.executeBody(Dataset, Model, QuerySolution) line: 142
SHACLSPARQLARQFunction(SHACLARQFunction).exec(Binding, ExprList, String,
FunctionEnv) line: 211
E_Function.evalSpecial(Binding, FunctionEnv) line: 69
...
{noformat}
So it seems to come in from StageMatchTriple. Maybe line 54 of SolverRX3 has
changed due to RDF-star work?
When I replaced my local copy of the Iter class with the "fixed" version, the
problem went away (without other changes to our code base). So I am optimistic
that this will resolve the problem.
I also don't see downsides of having Iter.filter implement Closeable. Do you?
I discovered this issue when I was walking through a long chain of close()
calls. It stopped at the filter iterator because that didn't implement
Closeable.
> Iter.filter does not close nested iterator
> ------------------------------------------
>
> Key: JENA-2151
> URL: https://issues.apache.org/jira/browse/JENA-2151
> Project: Apache Jena
> Issue Type: Bug
> Affects Versions: Jena 4.1.0
> Reporter: Holger Knublauch
> Priority: Major
> Attachments: IteratorFilter.java
>
>
> We recently attempted to upgrade our product to Jena 4.1.0 but noticed
> unclosed iterator warnings. I believe I have tracked it down to the fact that
> Iter.filter does not return a Closeable iterator and therefore does not close
> its nested (stream) iterator. I am attaching an implementation class that
> seems to fix it. With this, org.apache.jena.atlas.iterator.Iter.filter simply
> need to become
> {code:java}
> public static <T> Iterator<T> filter(final Iterator<? extends T> stream,
> final Predicate<T> filter) {
> return new IteratorFilter<T>(stream, filter);
> }
> {code}
> (Although Iter.filter hasn't changed for a while, I suspect some other
> changes to Jena caused the SPARQL engine to use it, and this has broken some
> scenarios for us - in particular calling SPIN/SHACL-SPARQL functions with
> BGPs in the WHERE clause).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)