Hi,
Using Aspose Cells for Java, version 22.8.
In our software product, we’ve seen spurious errors thrown by Aspose Cells when loading workbooks, depending on the amount of concurrent requests in the system.
The problem seems to have been introduced in version 22.7.
We were able to consistently trigger the error, in an isolated test-case, by loading the same stream of bytes (containing the content of an XLSX file) from multiple threads.
Sample code:
public class AsposeTest {
public static void main(String[] args) throws Exception {
byte[] bytes = Files.readAllBytes(Paths.get("input.xlsx"));
for (int workerId = 0; workerId < 10; workerId++) {
Thread thread = new Thread(new LoadingWorker(workerId, bytes));
thread.start();
}
}
static class LoadingWorker implements Runnable {
private final int workerId;
private final byte[] bytes;
public LoadingWorker(int workerId, byte[] bytes) {
this.workerId = workerId;
this.bytes = bytes;
}
@Override
public void run() {
try {
Thread.sleep((long) (Math.random() * 20));
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
for (int iteration = 0; iteration < 1000; iteration++) {
Thread.sleep((long) (Math.random() * 20));
new Workbook(inputStream);
System.out.println(workerId + " => " + iteration);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
When a only a single thread is used, no loading errors are reported.
However, when concurrency is increased, sometimes the loading of the Workbook will fail with the following exception:
Caused by: com.aspose.cells.CellsException: File is corrupted
at com.aspose.cells.y_m.warning(Unknown Source)
at com.aspose.cells.g6w.a(Unknown Source)
at com.aspose.cells.e4_.a(Unknown Source)
at com.aspose.cells.c3o.a(Unknown Source)
at com.aspose.cells.c3o.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.<init>(Unknown Source)
at x.y.z.AsposeTest$LoadingWorker.run(AsposeTest.java:40)
... 1 more
The above stack trace is with Aspose 22.8, running on Java 8.
On Aspose Cells 22.6, it is not possible to trigger the error.
This regression, starting from Aspose Cells 22.7, is a show-stopper, as random “File is corrupted” will occur at load.
Kind regards,
Taras
Sample workbook file: input.zip (1.9 MB)