spring integation and received date issue

445 views Asked by At

I'm using the latest spring integration (4.1.5) javax.mail (1.4.7) libraries but looks like this issue is sitting there from the beginning.

I'm trying to get received date from mail server via IMAP protocol but SI always returns null. This is because of row 301 in https://github.com/spring-projects/spring-integration/blob/4.1.x/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java

MimeMessage mimeMessage = new IntegrationMimeMessage((MimeMessage) filteredMessages[i]);

So instead of let me get IMAPMessage instance it makes me to get MimeMessage that has stub for method getReceivedDate:

public Date getReceivedDate() throws MessagingException {
return null;    
}

I see that header contains not null element Received so the only option I see is to parse this header manually.

Is it correct behaviour of SI? Bug or feature? And how to avoid manual parsing of received date header?

2

There are 2 answers

0
Gary Russell On BEST ANSWER

I've been looking at the Sun code; it uses the INTERNALDATE fetch item to populate the receivedDate property...

Line 1194 in javamail 1.5.2...

else if (item instanceof INTERNALDATE)
    receivedDate = ((INTERNALDATE)item).getDate();

However, Spring does not expose this; I have created a JIRA issue.

4
arnt On

The received date is available as the internaldate fetch item.

Parsing Received is a great deal of notfun, which is probably why the Spring developers haven't done it yet and why you'll hate doing it. See if internaldate will do.