Duplicate mail attachment names breaks the Message.getAttachments() interface 
contract
--------------------------------------------------------------------------------------

                 Key: CAMEL-3713
                 URL: https://issues.apache.org/jira/browse/CAMEL-3713
             Project: Camel
          Issue Type: Bug
          Components: camel-mail
    Affects Versions: 2.6.0
         Environment: Mac OSX 10.6.6
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-10M3261)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03-307, mixed mode)

            Reporter: Paul Mietz Egli
            Priority: Critical
             Fix For: 2.7.0


If the camel-mail component consumes a Multipart email message that contains 
two parts with the same filename, subsequent calls to {{DataHandler dh = 
Message.getAttachments().get("filename")}} result in a ClassCastException.  
This occurs because {{MailBinding.extractAttachmentsFromMultipart()}} calls 
{{CollectionHelper.appendValue(map, fileName, part.getDataHandler())}} to add 
an attachment to the Message attachments map.  If appendValue is passed a 
duplicate key, it converts the map value to an ArrayList and adds the existing 
value and the new value to the list.  The result is a Map that contains a mix 
of <String,DataSource> and <String,ArrayList>.

Fix is to NOT use CollectionHelper and to check for duplicate keys prior to 
adding an attachment.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to