Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bugfix: prevent LzoDecompressor from entering endless loop when a emp…

…ty lzo file comes.
  • Loading branch information...
commit f1d7661e38a7f10da46f817111745966ce71617e 1 parent 552b3f9
@angushe authored
View
3  src/java/com/hadoop/compression/lzo/LzoDecompressor.java
@@ -297,6 +297,9 @@ public synchronized int decompress(byte[] b, int off, int len)
// Check if there is data to decompress
if (compressedDirectBufLen <= 0) {
+ if (userBufLen <= 0 ) {
+ finished = true;
+ }
return 0;
}
View
9 src/test/com/hadoop/compression/lzo/TestLzopInputStream.java
@@ -43,6 +43,7 @@
private final String bigFile = "100000.txt";
private final String mediumFile = "1000.txt";
private final String smallFile = "100.txt";
+ private final String emptyFile = "0.txt";
@Override
protected void setUp() throws Exception {
@@ -82,6 +83,14 @@ public void testSmallFile() throws NoSuchAlgorithmException, IOException,
}
/**
+ * Test against a 0 line file.
+ */
+ public void testEmptyFile() throws NoSuchAlgorithmException, IOException,
+ InterruptedException {
+ runTest(emptyFile);
+ }
+
+ /**
* Test that reading an lzo-compressed file produces the same lines as reading the equivalent
* flat file. The test opens both the compressed and flat file, successively reading each
* line by line and comparing.
View
0  src/test/data/0.txt
No changes.
View
BIN  src/test/data/0.txt.lzo
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.