bbeaudreault commented on code in PR #5696:
URL: https://github.com/apache/hbase/pull/5696#discussion_r1500854815


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/CompressionContext.java:
##########
@@ -129,9 +130,25 @@ public void decompress(InputStream in, int inLength, 
byte[] outArray, int outOff
       } else {
         lowerIn.reset(in, inLength);
         IOUtils.readFully(compressedIn, outArray, outOffset, outLength);
+        // if the uncompressed size was larger than the configured buffer size 
for the codec,
+        // the BlockCompressorStream will have left an extra 4 bytes hanging. 
This represents a size
+        // for the next segment, and it should be 0. See HBASE-28390
+        if (lowerIn.available() == 4) {
+          int remaining = rawReadInt(lowerIn);
+          assert remaining == 0;
+        }
       }
     }
 
+    private int rawReadInt(InputStream in) throws IOException {

Review Comment:
   Actually, there is no IOUtils.readInt in commons-io. I realized that the 
IOUtils I was referring to (while on mobile) was a different library that we 
don't have a dependency on.
   
   We have a variety of methods for reading ints from byte[] or ByteBuffer, but 
not for InputStream that I can find. I could read the bytes into a byte[4] and 
use one of the utils, but I'd rather not allocate an unnecessary byte array. 
I'm going to leave this alone for now.



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