Hey All,
Not sure if this is a bug or not, but it seems to be. If forum feedback concurs, I'll create a patch.
In org.jboss.mail.mailbox.MailboxServiceImpl.moveFolder(...) [line 824], there appears to be a minor typo with the moveFolder function.
Below is the current version of the function. 'folder' is the folder to be moved, 'target' is the new parent folder, and name is the name of the folder. The function loads 'folder' by id, then loads the target folder by id. It then (assuming the folder and target aren't the same) removes 'folder' from its parent. Next, it appers to add the target folder (i.e., the new parent) to itself via the call "t.addFolder(t)" ---> I think this is the bug.
@Tx(TxType.REQUIRED) public Folder moveFolder(Folder folder, Folder target, String name) { Folder f = session.find(Folder.class, folder.getId()); Folder t = session.find(Folder.class, target.getId()); f.setName(name); if(folder.getId() != t.getId()) { f.getParent().getFolders().remove(f); t.addFolder(t); f.setParent(t); } session.persist(f); return f; }
... if(folder.getId() != t.getId()) { f.getParent().getFolders().remove(f); t.addFolder(f); // ---->> SUBTLE CHANGE HERE f.setParent(t); } ...