alex-plekhanov commented on code in PR #13089:
URL: https://github.com/apache/ignite/pull/13089#discussion_r3187220490


##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ClosableIteratorsHolder.java:
##########
@@ -119,37 +131,66 @@ private DelegatingIterator(Iterator<T> delegate) {
 
         /** {@inheritDoc} */
         @Override public boolean hasNext() {
-            return delegate.hasNext();
+            inUse = true;
+
+            try {
+                return delegate.hasNext();
+            }
+            finally {
+                inUse = false;
+            }
         }
 
         /** {@inheritDoc} */
         @Override public T next() {
-            return delegate.next();
+            inUse = true;
+
+            try {
+                return delegate.next();
+            }
+            finally {
+                inUse = false;
+            }
         }
 
         /** {@inheritDoc} */
         @Override public void remove() {
-            delegate.remove();
+            inUse = true;
+
+            try {
+                delegate.remove();
+            }
+            finally {
+                inUse = false;
+            }
         }
 
         /** {@inheritDoc} */
         @Override public void forEachRemaining(Consumer<? super T> action) {
-            delegate.forEachRemaining(action);
+            inUse = true;
+
+            try {
+                delegate.forEachRemaining(action);
+            }
+            finally {
+                inUse = false;
+            }
         }
 
         /** {@inheritDoc} */
         @Override public void close() throws Exception {
+            if (log.isDebugEnabled())
+                log.debug("Closing iterator [delegate=" + delegate + ", 
inUse=" + inUse + ']');
+
             Commons.close(closeable);
         }
     }
 
     /** */
     private final class CloseableReference extends WeakReference implements 
AutoCloseable {
         /** */
-        private CloseableReference(Object referent, Object resource) {
+        private CloseableReference(Object referent) {

Review Comment:
   WakReference related code is a protection from query leaking. Without this 
code there can be unclosed queries in memory if user doesn't close cursor 
properly.



-- 
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]

Reply via email to