Java Email IMAPclient can't despose

Dear,


I’m stuck with this annoying bug, and since the code contains obfuscated code, I can’t really fix the problem.

Starting up a new ImapClient works fine, but when I try to close the connection (by doing imapClient.dispose(). I get following Unhandledexception IllegalAccessError:

04 dec 2015 17:47:03,134 ERROR [DefaultQuartzScheduler_Worker-10] (JobRunShell.java:211) - Job DEFAULT.docShifterJob14 threw an unhandled Exception:
java.lang.IllegalAccessError: tried to access method com.aspose.email.system.exceptions.ThreadAbortException.()V from class com.aspose.email.internal.af.g
at com.aspose.email.internal.af.g.b(Unknown Source)
at com.aspose.email.ca.k(SourceFile:223)
at com.aspose.email.ca.dispose(SourceFile:195)
at com.aspose.email.xi.dispose(SourceFile:397)
at com.aspose.email.ga.dispose(SourceFile:680)
at com.aspose.email.CredentialsByHostClient.dispose(SourceFile:717)
at com.aspose.email.CredentialsByHostClient.dispose(SourceFile:777)
at com.aspose.email.ImapClient.dispose(SourceFile:503)

Therefor many instances of my imapclient stays open.
In attachment you’ll find more log data.

Has anyone experienced this also?
Thanks !!

Hi Samnang,

Thank you contacting Aspose support team.

Could you please share with us if you are using the latest version of Aspose.Email for Java 5.9.0? We have tested your claimed scenario with this latest version and the following code sample, and no exception is raised. Please try it with this latest version of the API and if the issue still persists, please share your sample code here for our investigation.

Sample Code:


ImapClient client = new ImapClient(“exchange.domain.com”, “username”, “password”);

client.setSecurityOptions(SecurityOptions.Auto);


client.selectFolder(ImapFolderInfo.IN_BOX);


System.out.println(client.listMessages().size());


client.dispose();

Hello,


Thank you for your reply. We’re running the latest version of the API (5.9.0).
Running your code doesn’t return this specific error.

I will try to write a proper test as soon as possible that simulates our goal and reproduces the error mentioned above.

Hi,


Thank you for sharing your feedback and please feel free to share your sample code with us for our further investigation.

Hello,


The problem has been fixed. For anyone who would also stumble on this issue :

This issue occurs when the the imapclient throws an exception (in my case when the imapclient failed to fetch a message by using imapclient.fetchMessage(msgId) ), followed by disconnecting the imapclient from the server by using imapclient.dispose(). This resulted in an IllegalState (as mentioned above).

In my case, the solution was to implement a mechanism, that wouldn’t run the dispose() method when the imapclient fails to fetch a message. (In the most simplest form this can be done using boolean logics).


Hi,


Thank you for the feedback and feel free to write us for any other query.
Hi,

We're still encoutering the mentioned IllegalAccessError. (Since aspose returns an error, we can't catch catch this as en Exception).

Is it possible to re-open this case?

Friendly regards,
Samnang

We're using Java 1.8 and the Aspose Email library v6.1.0
This is the exact code we're using: (The polling happens every 10 seconds)

//OPEN

ImapClient imapclient = new ImapClient(host, port, username, password, SecurityOptions.Auto);
imapclient.setConnectionTimeout(5000);

//PROCESS
Logger.info("Entering IMAP server", null);
try {
imapclient.selectFolder(ImapFolderInfo.IN_BOX);
ImapMessageInfoCollection coll = imapclient.listMessages();

Logger.info("2 FETCHING MESSAGES", null);
for (ImapMessageInfo msgInfo : coll) {
msgId = msgInfo.getUniqueId();
eml = imapclient.fetchMessage(msgId);
fileName = setFilename(eml, msgId);
Logger.debug("MESSAGEID = " + msgId, null);
Logger.debug("MESSAGENUMBERS = " + coll.size(), null);
Logger.info(String.format("Sending task for %s", fileName), null);

//own processing code

Logger.debug(String.format("Setting mail as deleted %s", fileName), null);
imapclient.deleteMessage(msgId);
}

} catch (Exception ex) {
Logger.error("Something went wrong while fetching imap email, trying again next polling", ex);
}

//CLOSE
try {
imapclient.commitDeletes();
imapclient.dispose();
} catch (Exception e) {
Logger.error("Failed to dispose imapclient", e);
} catch (Error e) {
Logger.error("Error when closing imapclient", e);
}

Hi Samnang,


I have observed the exception while calling ImapClient.dispose() and have logged it in our issue tacking system for further investigation by the product team. I shall write here as soon as some feedback is received in this regard. Ticket Id is : EMAILJAVA-33568.

The issues you have found earlier (filed as EMAILJAVA-33568) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.