ivankelly commented on a change in pull request #832: Issue 620: Close the 
fileChannels for read when they are idle
URL: https://github.com/apache/bookkeeper/pull/832#discussion_r174513109
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileChannelBackingCache.java
 ##########
 @@ -90,22 +88,18 @@ CachedFileChannel loadFileChannel(long logId) throws 
IOException {
      * @param cachedFileChannel
      */
     private void releaseFileChannel(long logId, CachedFileChannel 
cachedFileChannel) {
-        lock.writeLock().lock();
-        try {
-            if (cachedFileChannel.markDead()) {
-                try {
-                    cachedFileChannel.fileChannel.close();
-                } catch (IOException e) {
-                    LOG.warn("Exception occurred in 
ReferenceCountedFileChannel"
-                            + " while closing channel for log file: {}", 
cachedFileChannel);
-                } finally {
-                    IOUtils.close(LOG, cachedFileChannel.fileChannel);
-                }
-                // to guarantee the removed cachedFileChannel is what we want 
to remove.
-                fileChannels.remove(logId, cachedFileChannel);
+        if (cachedFileChannel.markDead()) {
+            // to guarantee the removed cachedFileChannel is what we want to 
remove.
+            fileChannels.remove(logId, cachedFileChannel);
+            // close corresponding fileChannel
+            try {
+                cachedFileChannel.fileChannel.close();
 
 Review comment:
   it would be better is cachedFileChannel had a close method rather than 
directly accessing members.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to