From 146d6e989fd766fa8b0936d6642c49714f90d881 Mon Sep 17 00:00:00 2001 From: bokken Date: Fri, 7 Feb 2014 09:49:46 -0600 Subject: [PATCH] Read until all bytes needed are read or EOF https://github.com/xerial/snappy-java/issues/62 --- src/main/java/org/xerial/snappy/SnappyFramedInputStream.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/xerial/snappy/SnappyFramedInputStream.java b/src/main/java/org/xerial/snappy/SnappyFramedInputStream.java index d10ba46..c3058c5 100644 --- a/src/main/java/org/xerial/snappy/SnappyFramedInputStream.java +++ b/src/main/java/org/xerial/snappy/SnappyFramedInputStream.java @@ -136,9 +136,7 @@ public final class SnappyFramedInputStream extends InputStream implements final byte[] actualHeader = new byte[expectedHeader.length]; final ByteBuffer actualBuffer = ByteBuffer.wrap(actualHeader); - // assume that if the input cannot read 4 bytes that something is - // wrong. - final int read = in.read(actualBuffer); + final int read = SnappyFramed.readBytes(in, actualBuffer); if (read < expectedHeader.length) { throw new EOFException( "encountered EOF while reading stream header");