Hi Aspose,
we use Aspose.Words in a multi-threading environment. We wanted to upgrade from 15.4 to 17.6 but sadly have noticed that Aspose.Words breaks when loading documents in more than one thread!
The exception is:
Caused by: com.aspose.words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.
at com.aspose.words.FileFormatUtil.zzZ(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at io.prc.violet.document.engine.ImporterIssue.lambda$main$0(ImporterIssue.java:24)
… 3 more
Caused by: java.lang.NullPointerException
at asposewobfuscated.zz99.zzZ(Unknown Source)
at asposewobfuscated.zz9K.zzZ(Unknown Source)
at asposewobfuscated.zzR9.zz4(Unknown Source)
at com.aspose.words.zz92.zzZ(Unknown Source)
at com.aspose.words.zz85.read(Unknown Source)
at com.aspose.words.zzZ9E.read(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)
… 7 more
Please reproduce with this code:
final ExecutorService es = Executors.newFixedThreadPool(10);
for (int i = 0;i<1000;i++) {
es.execute(() -> {
System.out.println(Thread.currentThread().getName());
try {
new Document("Template.docx");
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
es.shutdown();
es.awaitTermination(10, TimeUnit.MINUTES);
You can find ‘Template.docx’ as attachment, but I’m pretty sure it happens with every document.