rkhachatryan commented on code in PR #21679:
URL: https://github.com/apache/flink/pull/21679#discussion_r1090006907


##########
flink-dstl/flink-dstl-dfs/src/main/java/org/apache/flink/changelog/fs/ChangelogStreamHandleReaderWithCache.java:
##########
@@ -161,23 +161,28 @@ private FileInputStream openAndSeek(RefCountedFile 
refCountedFile, long offset)
 
     private DataInputStream wrapStream(Path dfsPath, FileInputStream fin) {
         return new DataInputStream(new BufferedInputStream(fin)) {
+            private boolean closed = false;
+
             @Override
             public void close() throws IOException {
-                try {
-                    super.close();
-                } finally {
-                    cache.computeIfPresent(
-                            dfsPath,
-                            (key, value) -> {
-                                value.release();
-                                if (value.getReferenceCounter() == 
NO_USING_REF_COUNT) {
-                                    cacheCleanScheduler.schedule(
-                                            () -> cleanCacheFile(dfsPath),
-                                            cacheIdleMillis,
-                                            TimeUnit.MILLISECONDS);
-                                }
-                                return value;
-                            });
+                if (!closed) {
+                    closed = true;

Review Comment:
   The returned `InputStream` might be used by different Tasks, i.e. different 
threads, right?
   
   So this flag should be thread-safe.
   Probably something like
   ```
   private AtomicBoolean closed = new AtomicBoolean(false);
   ...
   if (closed.compareAndSet(false, true)) { 
     // do close
   }
   ```
   WDYT?



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