When trying to create a new com.aspose.words.Document Java object from a Word document that was encrypted in a manner different from Word’s password protection, it appears that this causes Aspose to possibly go into an infinite loop of some kind, as it ends up causing an OOME. Below is the call stack. We are using Aspose Words version 20.10. Any help on this, or even confirmation on what is supported and what isn’t with regards to this, would be much appreciated. Thanks.
@jmyszka
I cannot reproduce exactly your problem, I’m using the version 23.1 of Aspose.Words, and I was able to load the file and clone it to another Document object, but I got the same exception when I save it.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-25034
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@jmyszka I have closed the defect WORDSNET-25034 created by Eduardo, since Aspose.Words cannot load such encrypted document. It detects it as TEXT document. To load the document it should be first decrypted.
@alexey.noskov the main problem is that it is consuming a lot of heap, leading to an OOME. In my version 20.10, I am unable to verify if just a little more heap is needed before an IncorrectPasswordException, or any exception in general, is thrown, or if the heap would just keep growing due to some infinite loop.
The point is that we were hoping that it would just reject the file instead of causing an OOME.
To clarify, we are seeing that the process does complete with an exception, but it takes a massive amount of heap, and a long time to process it. This heavily slows down the related server in meantime, and if anyone else tries to do the same thing during that time, it can lead to an OOME.
So, the main two complaints are the amount of heap and time it takes prior to rejecting the file.
private static class LoadingProgressCallback implements IDocumentLoadingCallback
{
/// <summary>
/// Ctr.
/// </summary>
public LoadingProgressCallback()
{
mLoadingStartedAt = new Date();
}
/// <summary>
/// Callback method which called during document loading.
/// </summary>
/// <param name="args">Loading arguments.</param>
public void notify(DocumentLoadingArgs args)
{
Date canceledAt = new Date();
long diff = canceledAt.getTime() - mLoadingStartedAt.getTime();
long ellapsedSeconds = TimeUnit.MILLISECONDS.toSeconds(diff);
if (ellapsedSeconds > MAX_DURATION)
throw new IllegalStateException(MessageFormat.format("EstimatedProgress = {0}; CanceledAt = {1}", args.getEstimatedProgress(), canceledAt));
}
/// <summary>
/// Date and time when document loading is started.
/// </summary>
private Date mLoadingStartedAt;
/// <summary>
/// Maximum allowed duration in sec.
/// </summary>
private static final double MAX_DURATION = 0.5;
}