[
https://issues.apache.org/jira/browse/CAMEL-27284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18148609#comment-18148609
]
Claus Ibsen edited comment on CAMEL-27284 at 11/21/26, 9:09 AM:
----------------------------------------------------------------
Fixed by https://github.com/apache/camel/pull/30531 (merged to main as
f30117d95ad3), fix version 4.24.0.
_Claude Code on behalf of davsclaus_
was (Author: davsclaus):
Fixed by https://github.com/apache/camel/pull/30531 (merged to main as
f30117d95ad3), released in 4.24.0.
_Claude Code on behalf of davsclaus_
> camel-jpa - JpaMessageIdRepository: a concurrent add of the same message id
> fails instead of returning false on PostgreSQL and SQL Server
> -----------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27284
> URL: https://issues.apache.org/jira/browse/CAMEL-27284
> Project: Camel
> Issue Type: Bug
> Components: camel-jpa
> Reporter: shashank
> Assignee: shashank
> Priority: Major
> Fix For: 4.24.0
>
>
> h3. What happens
> CAMEL-24132 (M4) made {{JpaMessageIdRepository.add}} return false when its
> insert fails on the unique key because another caller (node, thread) inserted
> the same message id at the same time. It recognises the failure only as
> {{SQLIntegrityConstraintViolationException}} or {{EntityExistsException}} in
> the cause chain:
> # The PostgreSQL driver ({{PSQLException}}, SQLState 23505) and the SQL
> Server driver (SQLState 23000) throw a plain {{SQLException}}, and Hibernate
> throws its {{ConstraintViolationException}} (a {{PersistenceException}}, not
> an {{EntityExistsException}}) with it as the cause, so on these databases
> {{add}} throws {{PersistenceException("Something went wrong ...")}}: the
> duplicate message fails (error handler, redelivery, dead letter channel)
> instead of being filtered. H2, Derby, MySQL and Oracle throw the subclass,
> which is why the module tests pass.
> # The check is inside the transaction: when the EntityManager is the
> transaction's ({{sharedEntityManager=true}}), the failed flush marks the
> transaction rollback-only, so the commit throws after the catch returned
> false, and {{add}} fails on every database.
> {{JpaKeyValueRepository}} (CAMEL-26736) already checks the SQLState class 23
> and recognises the duplicate outside the transaction.
> h3. How to reproduce
> {{JpaMessageIdRepositoryConcurrentInsertTest}}: the flush throws what
> Hibernate throws for a PostgreSQL unique violation
> (ConstraintViolationException -> SQLException state 23505): add throws; same
> with state 23000 (SQL Server); and with a transaction whose commit fails
> after the duplicate was recognised.
> h3. Fix
> The SQLState class 23 counts as a constraint violation (as in
> JpaKeyValueRepository), and a duplicate recognised in the transaction stays a
> duplicate when the commit then fails.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)