alex-plekhanov commented on code in PR #13089:
URL: https://github.com/apache/ignite/pull/13089#discussion_r3187201041
##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ClosableIteratorsHolder.java:
##########
@@ -97,18 +97,30 @@ private Reference nextRef(boolean blocking) {
}
/** */
- private AutoCloseable closeable(Object referent, Object resource) {
- if (!(resource instanceof AutoCloseable))
+ private AutoCloseable closeable(Object referent, Object rsrc) {
+ if (!(rsrc instanceof AutoCloseable))
return null;
- return new CloseableReference(referent, resource);
+ CloseableReference ref = new CloseableReference(referent);
+
+ refMap.put(ref, rsrc);
+
+ return ref;
}
/** */
private final class DelegatingIterator<T> implements Iterator<T>,
AutoCloseable {
/** */
private final Iterator<T> delegate;
+ /**
+ * This variable is required to keep reference to current instance
while delegate call
+ * (hasNext/next/remove/forEachRemaining) is not completed. We
actually don't care about variable value and
+ * thread safety, it's only to prevent premature garbage collection
and iterator closing before returning
+ * result to the user.
+ */
+ private boolean inUse;
Review Comment:
It's not debug related flag. There is a javadoc comment describing why this
flag is needed. It not masks the exception it prevents to garbage-collect
iterator object before delegate object returns result.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]