linkedin / migz

Multithreaded, gzip-compatible compression and decompression, available as a platform-independent Java library and command-line utilities.
BSD 2-Clause "Simplified" License
79 stars 11 forks source link

failed with using MiGzInputStream #4

Closed zhiyouWu closed 4 years ago

zhiyouWu commented 4 years ago

hello,developers, when I use MiGzInputStream with availableProcessors(), it happened some exception. For example: OOM or IndexOutBounds. My code is:

int threadCount = Runtime.getRuntime().availableProcessors();
ByteArrayInputStream in = new ByteArrayInputStream(compressedBytes);
MiGzInputStream miGzInputStream = new MiGzInputStream(inputStream, threadCount);
ByteArrayOutputStream out = new ByteArrayOutputStream();
MiGzBuffer buffer;
while ((buffer = miGzInputStream.readBuffer()) != null) {
      out.write(buffer.getData(), 0, buffer.getLength());
}
out.close();

And how I can resolve it? Thanks