Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix bug where LZO header or block header data may fall on read boundary

HDFS's read() call can return less data than asked for if
the header falls on a block boundary. We need to read the
data fully.
  • Loading branch information...
commit f3bc3f8d003bb8e24f254b25bca2053f731cdd58 1 parent 559e918
todd authored
Showing with 3 additions and 6 deletions.
  1. +3 −6 src/java/com/hadoop/compression/lzo/LzopInputStream.java
View
9 src/java/com/hadoop/compression/lzo/LzopInputStream.java
@@ -32,6 +32,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.io.compress.BlockDecompressorStream;
import org.apache.hadoop.io.compress.Decompressor;
+import org.apache.hadoop.io.IOUtils;
public class LzopInputStream extends BlockDecompressorStream {
@@ -60,9 +61,7 @@ public LzopInputStream(InputStream in, Decompressor decompressor,
*/
private static int readInt(InputStream in, byte[] buf, int len)
throws IOException {
- if (0 > in.read(buf, 0, len)) {
- throw new EOFException();
- }
+ IOUtils.readFully(in, buf, 0, len);
int ret = (0xFF & buf[0]) << 24;
ret |= (0xFF & buf[1]) << 16;
ret |= (0xFF & buf[2]) << 8;
@@ -88,9 +87,7 @@ private static int readHeaderItem(InputStream in, byte[] buf, int len,
* and ignoring most everything else.
*/
protected void readHeader(InputStream in) throws IOException {
- if (0 > in.read(buf, 0, 9)) {
- throw new EOFException();
- }
+ IOUtils.readFully(in, buf, 0, 9);
if (!Arrays.equals(buf, LzopCodec.LZO_MAGIC)) {
throw new IOException("Invalid LZO header");
}
Please sign in to comment.
Something went wrong with that request. Please try again.