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

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
 ##########
 @@ -999,51 +1015,47 @@ public ByteBuf internalReadEntry(long ledgerId, long 
entryId, long location)
         ByteBuf sizeBuff = sizeBuffer.get();
         sizeBuff.clear();
         pos -= 4; // we want to get the ledgerId and length to check
-        BufferedReadChannel fc;
-        try {
-            fc = getChannelForLogId(entryLogId);
+        try (EntryLogBufferedReadChannel bc = getChannelForLogId(entryLogId)){
+            if (readFromLogChannel(entryLogId, bc, sizeBuff, pos) != 
sizeBuff.capacity()) {
+                throw new Bookie.NoEntryException("Short read from entrylog " 
+ entryLogId,
+                        ledgerId, entryId);
+            }
+            pos += 4;
+            int entrySize = sizeBuff.readInt();
+
+            // entrySize does not include the ledgerId
+            if (entrySize > maxSaneEntrySize) {
+                LOG.warn("Sanity check failed for entry size of " + entrySize 
+ " at location " + pos + " in "
 
 Review comment:
   nit:
   
   it can be written with '{}'

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to