You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Tellier Benoit (JIRA)" <ji...@apache.org> on 2014/12/18 15:52:13 UTC

[jira] [Updated] (MAILBOX-205) Messages get copied instead of moved when moveBatchSize is set in StoreMailboxManager

     [ https://issues.apache.org/jira/browse/MAILBOX-205?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tellier Benoit updated MAILBOX-205:
-----------------------------------
    Description: 
I was working on MAILBOX-146 to add a batch size where needed in the StoreMessageManager ( setFlags, deleteMarkedInMailbox, recent, copy, move ) and I add a look at the code of the StoreMailboxManager.

I found a call to a method named **copyTo** in an other method named **moveMessages**...

I might have missed something, but I think this might create a bug when moveBatchSize is not null....

  was:
I was working on MAILBOX-146 to add a batch size where needed in the StoreMessageManager ( setFlags, deleteMarkedInMailbox, recent, copy, move ) and I add a look at the code of the StoreMailboxManager.

I found a call to a method named **copyTo** in an other method named **moveMessages**...

>From the code : 

```
    @Override
    @SuppressWarnings("unchecked")
    public List<MessageRange> moveMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
        StoreMessageManager<Id> toMailbox = (StoreMessageManager<Id>) getMailbox(to, session);
        StoreMessageManager<Id> fromMailbox = (StoreMessageManager<Id>) getMailbox(from, session);

        if (moveBatchSize > 0) {
            List<MessageRange> movedRanges = new ArrayList<MessageRange>();
            Iterator<MessageRange> ranges = set.split(moveBatchSize).iterator();
            while (ranges.hasNext()) {
                movedRanges.addAll(fromMailbox.copyTo(ranges.next(), toMailbox, session));
            }
            return movedRanges;
        } else {
            return fromMailbox.moveTo(set, toMailbox, session);
        }
    }
```

Shouldn't it be :

```
    @Override
    @SuppressWarnings("unchecked")
    public List<MessageRange> moveMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
        StoreMessageManager<Id> toMailbox = (StoreMessageManager<Id>) getMailbox(to, session);
        StoreMessageManager<Id> fromMailbox = (StoreMessageManager<Id>) getMailbox(from, session);

        if (moveBatchSize > 0) {
            List<MessageRange> movedRanges = new ArrayList<MessageRange>();
            Iterator<MessageRange> ranges = set.split(moveBatchSize).iterator();
            while (ranges.hasNext()) {
                movedRanges.addAll(fromMailbox.moveTo(ranges.next(), toMailbox, session));
            }
            return movedRanges;
        } else {
            return fromMailbox.moveTo(set, toMailbox, session);
        }
    }
```

I might have missed something, but I think this might create a bug when moveBatchSize is not null....


> Messages get copied instead of moved when moveBatchSize is set in StoreMailboxManager
> -------------------------------------------------------------------------------------
>
>                 Key: MAILBOX-205
>                 URL: https://issues.apache.org/jira/browse/MAILBOX-205
>             Project: James Mailbox
>          Issue Type: Bug
>         Environment: Any
>            Reporter: Tellier Benoit
>
> I was working on MAILBOX-146 to add a batch size where needed in the StoreMessageManager ( setFlags, deleteMarkedInMailbox, recent, copy, move ) and I add a look at the code of the StoreMailboxManager.
> I found a call to a method named **copyTo** in an other method named **moveMessages**...
> I might have missed something, but I think this might create a bug when moveBatchSize is not null....



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org