We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Reading from GZIPInputStream sometimes throws bogus "File is corrupted" in 22.7, 22.8 and 22.9

Using Aspose Cells for Java, version 22.9.

Sample code:

byte[] uncompressedBytes = Files.readAllBytes(Paths.get("input.xlsx"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(outputStream);
gzipOutputStream.write(uncompressedBytes);
gzipOutputStream.close();
byte[] compressedBytes = outputStream.toByteArray();

GZIPInputStream inputStream = new GZIPInputStream(new ByteArrayInputStream(compressedBytes));
Workbook workbook = new Workbook(inputStream);

Exception stack trace:

Exception in thread "main" com.aspose.cells.CellsException: File is corrupted
	at com.aspose.cells.t_d.warning(Unknown Source)
	at com.aspose.cells.u78.a(Unknown Source)
	at com.aspose.cells.f7l.a(Unknown Source)
	at com.aspose.cells.o9.a(Unknown Source)
	at com.aspose.cells.o9.a(Unknown Source)
	at com.aspose.cells.Workbook.a(Unknown Source)
	at com.aspose.cells.Workbook.<init>(Unknown Source)
	at <sample code>

The code above works on 22.6, but throws the error shown above since 22.7.

Kind regards,
Taras

input.zip (367.1 KB)

@TarasTielkes,

Thanks for the template Excel file.

Please notice, I am able to reproduce the issue as you mentioned by using your template file. I found when reading from GZIPInputStream sometimes throws “File is corrupted” error in v22.7 and newer versions, it works fine though if I use v22.6. I have logged a ticket with an id “CELLSJAVA-44898” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@TarasTielkes,

This is to inform you that your issue has been resolved. The fix will be included in our upcoming release (Aspose.Cells v22.10) which is scheduled in the first/second week of October 2022. You will also be notified when the next version is released.

Hi @Amjad_Sahi,

Out of curiosity, what was the root cause of the bug?

Thanks,
Taras

@TarasTielkes,

There was an internal bug in the APIs when reading from GZIPInputStream. Anyways, we will soon share the actual root cause of the issue with you.