Excuse posting to both user and developer, but I thought this issue was possibly 
serious enough to warrant both...

I am using James 2.1.3

I have written a mailet in which I am trying to filter a subset of the recipents of a 
MimeMessage so that they can be processed differently from the rest.

The problem I have is that the MimeMessage I get from James is wrapped in a 
MimeMessageWrapper which appears to be causing me no end of trouble. 

Consider the following.  I have a couple of filters that match an incoming 
mimeMessage.  The MimeMessgae has 5 recipients.  The first filter in my mailet is 
intended to catch 2 recipients, and when it does so, it should strip those recipents 
off the message.  The second filter then receives the message with the remaining 3 
recipients.  It strips off another 2, and the final message as one recipient and is 
processed normally.

The idea is that the filters can be applied to the mail to transform the mail for the 
specified recipients into a request to another system.

OK.  To do this I am making calls to MimeMessage.getRecipents(RecipentType), working 
out recipients match, and then calling MimeMessage.setRecipents(RecipentType, 
remainingAddresses) to decrease the number of recipients for the next filter.

I have had a look at the source for MimeMessageWrapper, and what appears to be 
happening is that may call to MimeMessage.setRecipents(RecipentType, 
remainingAddresses) works OK, but when I then call 
MimeMessage.getRecipents(RecipentType) for the second filter, the recipient list is 
unchanged. 

It appears MimeMessage.setRecipents(RecipentType, remainingAddresses) does NOT update 
its cached headers, so subsequent calls to getRecipients are incorrect.  
This is not true for specific some header manipulation functions (e.g setSubject, 
where the cached headers and the message headers are both updated.

The public functions that from a quick look do not appear to update the in memory 
cache of the headers, and therefore probably need attention are:

addRecipients
setContentId
setContentMD5
setFrom 
setRecipients
setReplyTo

The following look like they are probably OK, as they update the header cache:

setSubject
setSentDate

The following are also OK because the gets read from the cached message not the cached 
header:

setContentLanguage
setDescription
setDisposition
setFileName
setFlags


Also, getSize and getMessageSize appears to return the size of the original message, 
not the size of the cached message, which may well have changed.  I don't know what 
this is being used for, so I don't know whether it is a problem or not

Have I got this totally wrong, or is there a serious set of bugs here?

Thanks in advance
N


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to