prosgarz35 opened a new pull request, #3205:
URL: https://github.com/apache/james-project/pull/3205
### Rationale & Context
In `PostgresMessageMapper.moveReactive`, the message move operation
executes as a sequence of two separate steps:
1. `copyReactive(mailbox, original)` — inserts the copied message entry
into the target mailbox in PostgreSQL.
2. `mailboxMessageDAO.deleteByMailboxIdAndMessageUid(...)` — deletes the
original message entry from the source mailbox.
If the subsequent deletion step fails (e.g. database timeout, transient
disconnection, or cancellation), the copied message remains in the target
mailbox while the original message remains intact in the source mailbox. This
causes
permanent message duplication for the user.
In addition, `move` and `move(Mailbox, List<MailboxMessage>)` contained
redundant overrides where `move(Mailbox, MailboxMessage)` did not leverage
`MailboxReactorUtils.block`, and the batch method unnecessarily duplicated
default
interface logic.
### Changes
1. **Add compensating rollback on failure in `moveReactive`**:
- If deleting the message from the source mailbox fails, an
`onErrorResume` rollback removes the newly copied entry from the target mailbox
before re-throwing the error.
- Prevents orphaned duplicates if the operation fails midway.
2. **Clean up `move` contract in `PostgresMessageMapper`**:
- Delegate single-message blocking `move` via
`MailboxReactorUtils.block(moveReactive(mailbox, original))`.
- Remove redundant `move(Mailbox, List<MailboxMessage>)` override to
let the default interface method handle batch processing reactively.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]