Tellier Benoit created MAILBOX-205:
--------------------------------------
Summary: 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**...
>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....
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]