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

Free Support Forum - aspose.com

NullPointerException when trying to delete item from the folder

Hi
I’m trying to delete item from folder by : FolderInfo.deleteChildItem
and getting next exception, what could be an issue , why your library has such an exception ?

Oct 17 12:07:36 java.lang.NullPointerException
Oct 17 12:07:36 at com.aspose.email.ake.a(SourceFile:263)
Oct 17 12:07:36 at com.aspose.email.awt.a(SourceFile:206)
Oct 17 12:07:36 at com.aspose.email.awt.a(SourceFile:177)
Oct 17 12:07:36 at com.aspose.email.acx.c(SourceFile:1912)
Oct 17 12:07:36 at com.aspose.email.acx.a(SourceFile:937)
Oct 17 12:07:36 at com.aspose.email.aox.a(SourceFile:1070)
Oct 17 12:07:36 at com.aspose.email.FolderInfo.deleteChildItems(SourceFile:1142)
Oct 17 12:07:36 at com.aspose.email.FolderInfo.deleteChildItem(SourceFile:1070)

Thanks

@slavago,

Please share the code sample that you are using so that we can reproduce this issue and assist you further.

Well, it’s not that easy, as I need to provide you our entire product, as there some logic that can’t be provided as a sample, and data as well, could you please tell according to your code, what can cause this issue ?
Is missing child id can cause this ?
Thanks

@slavago,

The method FolderInfo.deleteChildItem() expects the entry id of the message in byte format. You may use the code snippet given below to delete the message.

PersonalStorage pst = PersonalStorage.fromFile(pstFileName);
FolderInfo folderInfo = pst.getRootFolder();
MessageInfoCollection messageInfoCollection = folderInfo.getContents();
MessageInfo messageInfo = (MessageInfo) messageInfoCollection.get_Item(0);
folderInfo.deleteChildItem(messageInfo.getEntryId());

We hope that this answered your question. Please feel free to reach us if additional information is required.

Well, yes, I know that and let’s say this method works till some point and it throws an exception.
So, it’s not crashing everytime I call this method, but in my case 7th passed ok, and 8 call throws this exception.

Also, the deleteChildItem get byte[], what is the way you expect to convert string that received in addMapiMessageItem to byte[] that expected in the deleteChildItem ?

Thanks

@slavago,

NullPointerException is a RuntimeException in Java which arises due to the null value assigned to an object. You can find additional detail on NullPointerException by visiting the link given below.
NullPointerException
To convert String to Byte Array, you may use the .getBytes() method of the String Class.

@muhammadahmad,
Believe me, after 20 years in Java development I know what is NullPointerException,
The issue is that exception thrown from your library, and this is actually shouldn’t happen.
Please note also, to deleteChildItem method can’t accept String.getBytes() (please try do to that and you’ll be surprised), it need to get Base64.decode(String.getBytes()).

As for samples to reproduce the problem, I can’t provide it, sometimes life is more complex than few lines of code. If you’ll see in history of my questions here, you’ll see that I found many bugs in your library, and some of those bugs were found without sample, but your team here was providing me temporary version of lib with more debug info that helped to all of us to solve the issue.
So, please escalate this case, as problem is there, I don’t know what is the problem, it’s always reproducible in our code with probably our specific data, but I can’t provide you a sample to reproduce, but this doesn’t vanish the problem. So, let’s work together to make our products better, and let’s think how we can find the problem, maybe temporary version with more log or some debug information. At the end, your library throws NullPointer and we need to understand why.

Thanks

@slavago,

We apologize if any part of our answer felt unpleasant. We always value the concerns of our customers. We tried to reproduce this issue using a PST file that contained more than 250 emails. We looped through those and deleted them. All emails were deleted successfully without generating the exception.
We will investigate this issue further to see how this can be traced and reproduced. We will let you know as soon as more information is available.

@muhammadahmad
In my case it’s master recurrent events that are added, retrieved , updated, inserted again and deleted. All this due to fact that we didn’t find any other way to update existing calendar event (add exceptions to the recurrent event)after it was added to the PST.

Thanks

@slavago

We are sorry for inconvenience.
We are working on this issue and will let you know as soon as we have more information to share.

@muhammadahmad ,
If you can provide custom version with more logs / debug information I can very easy to catch this case , as it’s reproducible very fast here in our app.

@slavago,

We have logged your request for a custom build of the API in our issue tracking system as EMAILJAVA-34439. We will update you here as more information is available.

Is there any ETA on this ? As this issue influence our production.
Thanks

@slavago,

We apologize for the delay. Please share the version of Aspose.Email for Java API that you are using.

@muhammadahmad
I’m running on the latest 18.9 on Mac MojaveOS or Linux CentOS 7.

Thanks

@slavago,

Thank you for your feedback. We have updated this information against the ticket EMAILJAVA-34439. We will update you here as soon as additional information is available.

Hi, is there any estimation ? Thanks

@slavago,

We were able to reproduce the issue. We are working to fix it in both .NET and Java API. We will update you as more information is available.

Great, thanks. Waiting