Exception “NegativeArraySizeException” while creating PST

Hi,
Trying to split Big Size PST file to small size PST files. For that purpose I am extracting the MapiMessage from Big PST and creating new PST by adding extracted MapiMessages . for Example:

Given Big PST : Size 1 GB
Requirement : Break to Small PST having size around 100 MB.
Output : Output will be generate approx 10 PSTs having each size around 100 MB.

Core Logic to read MapiMessage from Src and add to Target PST file:

PersonalStorage srcPst = PersonalStorage.fromFile(" D:\sources\input.pst", false);
PersonalStorage targetPst = PersonalStorage.create(“destinationFolder+fileName”,0);

FolderInfo srcFolder = srcPst.getRootFolder().getSubFolder("Inbox);
FolderInfo targetFolder = targetPst.getRootFolder().addSubFolder("Inbox);

IGenericEnumerator enumerable = srcFolder.enumerateMapiMessages().iterator();
while (enumerable.hasNext()){
MapiMessage message = enumerable.next();
targetFolder.addMessage(message);
}

While executing the above logic , Got error like:

exceptionjava.lang.NegativeArraySizeException: -20
Exception in thread “main” java.lang.NegativeArraySizeException: -20
at com.aspose.email.zzn.a(SourceFile:597)
at com.aspose.email.zzn.(SourceFile:125)
at com.aspose.email.zbfh.a(SourceFile:457)
at com.aspose.email.zahx.a(SourceFile:2198)
at com.aspose.email.zahx.a(SourceFile:702)
at com.aspose.email.zawg.a(SourceFile:1132)
at com.aspose.email.FolderInfo.addMessage(SourceFile:758)

We are planning to utilize this library for our requirement but blocked bcoz of this issue.
It needs to be fixed as this is blocker issue to use in our requirement.

@arvind.glaitm,
Welcome to our community! Thank you for the issue description. Unfortunately, I have not managed to reproduce the error on my side. It looks like the issue is specific to some PST files or messages. Please check the issue with the latest version of Aspose.Email. If the error persists, please prepare a PST file example for us to investigate the issue further.

Hi Andrey,

Thanks for response.

Please find my observation when I tried to split the same file into different sizes PSTs

Input File Size : 808 MB

Output PSTs size : 4 MB , splitted successfully
Output PSTs size : 10 MB , splitted successfully
Output PSTs zise : 2 MB , split fails after producing 55 PSTs , and while creating 56th I got the above mentioned error.

As The Input file is same in all the scenario, seems there is no problem with Input PST file. And Regarding the Particular message issue If there is some problem with message then that message should create problem in all the scenarios.

I am using latest Aspose Email dependency-

com.aspose
aspose-email
21.6
jdk16

The PST file that I am using is official confidential file , so sorry can not share the same.I will try to create any new PST file and check if issue exist with that one, will share.

Could you please suggest if is there any way to print the error stack trace in more detail or any debug step that I can follow to get more detail.

@arvind.glaitm,
Thank you for the additional information. Unfortunately, I know no way to print the stack trace in more detail. I added a ticket with ID EMAILJAVA-34921 in our tracking system. Our development team will investigate this case. I will inform you of any progress.

@arvind.glaitm,
Unfortunately, our development team has not managed to reproduce the error you described above. Could you share a comprehensive code example splitting the PST file, please? All the same, it would be great if you could prepare some PST file that we can use to investigate this issue.