修复ZipUtil中zlib和unZlib调用后资源未释放问题(issue#3976@Github)

This commit is contained in:
Looly
2025-06-20 10:43:14 +08:00
parent d2d5e3092f
commit 8aff7bfb66

View File

@@ -942,7 +942,7 @@ public class ZipUtil {
*/
public static byte[] zlib(final InputStream in, final int level, final int length) {
final ByteArrayOutputStream out = new ByteArrayOutputStream(length);
Deflate.of(in, out, false).deflater(level);
Deflate.of(in, out, false).deflater(level).close();
return out.toByteArray();
}
@@ -994,7 +994,7 @@ public class ZipUtil {
*/
public static byte[] unZlib(final InputStream in, final int length) {
final ByteArrayOutputStream out = new ByteArrayOutputStream(length);
Deflate.of(in, out, false).inflater();
Deflate.of(in, out, false).inflater().close();
return out.toByteArray();
}