Exception when FromRepository tries to delete a message
-------------------------------------------------------
Key: JAMES-337
URL: http://nagoya.apache.org/jira/browse/JAMES-337
Project: James
Type: Bug
Components: MailStore & MailRepository
Versions: 2.2.0
Reporter: Hes Siemelink
I am trying to get a FromRepository in the air, that will respool messages that
were dumped in an error repository earlier.
This is my configuration:
<!-- Respool messages that could not be delivered earlier -->
<mailet match="SubjectStartsWith=Respool-Out" class="FromRepository">
<repositoryPath> file://../../../../spool/outgoing-undeliverable/
</repositoryPath>
<processor> root </processor>
<delete> true </delete>
</mailet>
However, when this mailet is triggered I get the following exception.
java.lang.ClassCastException
at
org.apache.james.mailrepository.AvalonMailRepository.remove(AvalonMailRepository.java:372)
at
org.apache.james.transport.mailets.FromRepository.service(FromRepository.java:132)
at
org.apache.james.transport.LinearProcessor.service(LinearProcessor.java:407)
at
org.apache.james.transport.JamesSpoolManager.process(JamesSpoolManager.java:451)
at
org.apache.james.transport.JamesSpoolManager.run(JamesSpoolManager.java:360)
at java.lang.Thread.run(Unknown Source)
Messages seem to be respooled but are not deleted.
Proposed fix: Make AvalonMailRepository.remove(Collection) take Collections of
Strings as well as Collections of MailImpl objects.
Proposed new implementation:
/**
* Removes a Collection of mails from the repository
* @param mails The Collection of <code>MailImpl</code>'s to delete
* @throws MessagingException
* @since 2.2.0
*/
public void remove(Collection mails) throws MessagingException {
Iterator delList = mails.iterator();
while (delList.hasNext()) {
Object next = delList.next();
if (next instanceof MailImpl) {
remove( (MailImpl) next);
}
else if (next instanceof String) {
remove( (String) next);
}
else if (next instanceof Collection) {
remove( (Collection) next);
}
}
}
Diff against 2.2.0 release tag:
Index: AvalonMailRepository.java
===================================================================
--- AvalonMailRepository.java (revision 37982)
+++ AvalonMailRepository.java (working copy)
@@ -369,7 +369,16 @@
public void remove(Collection mails) throws MessagingException {
Iterator delList = mails.iterator();
while (delList.hasNext()) {
- remove((MailImpl)delList.next());
+ Object next = delList.next();
+ if (next instanceof MailImpl) {
+ remove( (MailImpl) next);
+ }
+ else if (next instanceof String) {
+ remove( (String) next);
+ }
+ else if (next instanceof Collection) {
+ remove( (Collection) next);
+ }
}
}
@@ -404,7 +413,7 @@
*
*/
public Iterator list() {
- // Fix ConcurrentModificationException by cloning
+ // Fix ConcurrentModificationException by cloning
// the keyset before getting an iterator
final ArrayList clone;
synchronized(keys) {
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]