Skip to content

Commit

Permalink
Fixed a bug in gzip's decompress that didn't close InputStream.
Browse files Browse the repository at this point in the history
  • Loading branch information
kijima committed Jul 2, 2020
1 parent abfa0ad commit 7ede31b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<groupId>jp.co.yahoo.yosegi</groupId>
<artifactId>yosegi</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
<packaging>jar</packaging>
<name>Yosegi</name>
<description>Yosegi package.</description>
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/jp/co/yahoo/yosegi/compressor/GzipCompressor.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ public byte[] decompress(

ByteArrayInputStream byteArrayIn =
new ByteArrayInputStream( data , start + Integer.BYTES , length );
GZIPInputStream in = new GZIPInputStream( byteArrayIn , 1024 * 256 );

byte[] retVal = new byte[dataLength];
InputStreamUtils.read( in , retVal , 0 , dataLength );
try ( GZIPInputStream in = new GZIPInputStream( byteArrayIn , 1024 * 256 ); ) {
InputStreamUtils.read( in , retVal , 0 , dataLength );
}

return retVal;
}
Expand All @@ -120,9 +120,9 @@ public int decompressAndSet(

ByteArrayInputStream byteArrayIn =
new ByteArrayInputStream( data , start + Integer.BYTES , length );
GZIPInputStream in = new GZIPInputStream( byteArrayIn , 1024 * 256 );

InputStreamUtils.read( in , buffer , 0 , dataLength );
try ( GZIPInputStream in = new GZIPInputStream( byteArrayIn , 1024 * 256 ); ) {
InputStreamUtils.read( in , buffer , 0 , dataLength );
}

return dataLength;
}
Expand Down

0 comments on commit 7ede31b

Please sign in to comment.