Arsnael commented on code in PR #1786:
URL: https://github.com/apache/james-project/pull/1786#discussion_r1390597662
##########
mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/dao/PostgresMailboxDAO.java:
##########
@@ -77,85 +76,74 @@ public Mono<Mailbox> create(MailboxPath mailboxPath,
UidValidity uidValidity) {
public Mono<MailboxId> rename(Mailbox mailbox) {
Preconditions.checkNotNull(mailbox.getMailboxId(), "A mailbox we want
to rename should have a defined mailboxId");
- return postgresExecutor.dslContext()
- .flatMap(dslContext -> rename(mailbox, dslContext))
+ return postgresExecutor.executeSingleRowList(dslContext ->
rename(mailbox, dslContext))
+ .flatMap(records -> {
+ if (records.size() == 0) {
+ return Mono.error(new
MailboxNotFoundException(mailbox.getMailboxId()));
+ } else {
+ return Mono.just(mailbox.getMailboxId());
+ }
+ })
.onErrorMap(e -> e instanceof DataAccessException &&
e.getMessage().contains(DUPLICATE_VIOLATION_MESSAGE),
throwable -> new MailboxExistsException(mailbox.getName()));
}
- private Mono<MailboxId> rename(Mailbox mailbox, DSLContext dslContext) {
+ private Mono<List<Record>> rename(Mailbox mailbox, DSLContext dslContext) {
return Flux.from(dslContext.update(TABLE_NAME)
Review Comment:
I find the JOOQ doc not easy to navigate but... I'm finding strange an
update on a record where we match the PK has to return a flux. Not possible to
return a Mono? Returning a Mono<List<Record>> for a rename looks... rather
strange to me
--
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]