[ 
https://issues.apache.org/activemq/browse/SM-1569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45584#action_45584
 ] 

Ivan Pryvalov commented on SM-1569:
-----------------------------------

class AbstractMailMarchaller is not thread-safe:

It means if I will send 2 excganges to some SU based on servicemix-mail 
component, after first exchange is processed, it is executed cleanUp method of 
AbstractMarshaller, and while executing second exchange we get 
"FileNotFoundException".

Schema:


1 Exchange:  -> AR SA  S   C



2 Exchange:   ------->  AR   SA     S    C


AR - AcceptionRequest
SA - SavingAttachments
S - Sending e-mail
C - CleanUp.

Troubles is in point 2Exchange.S  (after 1.Exchange.C) 





I would to replace 

    private List<File> temporaryFiles = new ArrayList<File>();

 with:

   private Map< String, List<File> > temporaryFilesMap = 
Collections.synchronizedMap(new HashMap<String, List<File> >());


and:

protected final void addTemporaryResource(String id, File tmpFile) {
        if (!this.temporaryFilesMap.containsKey(id))
            this.temporaryFilesMap.put(id, new ArrayList<File>());
        this.temporaryFilesMap.get(id).add(tmpFile);
    }

and:

    public final void cleanUpResources(String id) {
        List<File> list = this.temporaryFilesMap.get(id);
        if (list!=null){           
            for (File f : list) {
                f.delete();
            }
            list.clear();
            this.temporaryFilesMap.remove(id);
        }
    }


And do necessary changes in code from other classes (also it is needed to 
update tests to avoid NullPointerException, I mean following:  replace InOnly 
exchange = new InOnlyImpl() with  InOnly exchange = new InOnlyImpl("id")) 

> CleanUp tempFiles-attachments is not thread-safe
> ------------------------------------------------
>
>                 Key: SM-1569
>                 URL: https://issues.apache.org/activemq/browse/SM-1569
>             Project: ServiceMix
>          Issue Type: Bug
>          Components: servicemix-mail
>    Affects Versions: 3.3
>         Environment: SMX-3.3
>            Reporter: Ivan Pryvalov
>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to