CAMEL-23428: Fix flaky RabbitMQProducerInvalidExchangeIT test#22980
CAMEL-23428: Fix flaky RabbitMQProducerInvalidExchangeIT test#22980gnodet merged 2 commits intoapache:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
✅ POM dependency changes: targeted tests included Modules affected by dependency changes (1)
All tested modules (8 modules)
|
| // Spring AMQP may wrap ShutdownSignalException in AmqpException depending on timing | ||
| Throwable cause = exception.getCause(); | ||
| while (cause != null && !(cause instanceof ShutdownSignalException)) { | ||
| cause = cause.getCause(); | ||
| } | ||
| Assertions.assertInstanceOf(ShutdownSignalException.class, cause, | ||
| "Expected ShutdownSignalException in cause chain, but got: " + exception.getCause()); |
There was a problem hiding this comment.
I think we could use https://javadoc.io/doc/org.assertj/assertj-core/3.27.7/org/assertj/core/api/AbstractThrowableAssert.html#hasCauseInstanceOf(java.lang.Class)
it will allow to have shorter code and also a better error message with the full stack trace.
Especially given that it sounds like a stab in the dark that the AMQPEXception is wrapping the shutdownexception. At least, if i tis not the case, i twill help to investigate more.
There was a problem hiding this comment.
Good point, thanks! Switched to assertThat(exception).hasRootCauseInstanceOf(ShutdownSignalException.class) — uses hasRootCauseInstanceOf rather than hasCauseInstanceOf since the ShutdownSignalException is the deepest cause in both the direct and wrapped scenarios. This also gives the full stack trace on failure as you suggested.
Claude Code on behalf of Guillaume Nodet
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CAMEL-23428
The
RabbitMQProducerInvalidExchangeIT.testProducertest is flaky because it asserts the direct cause ofCamelExecutionExceptionisShutdownSignalException. However, Spring AMQP may wrap the underlyingShutdownSignalExceptionin anAmqpExceptiondepending on timing, causing intermittent failures.Fix: Use AssertJ's
hasRootCauseInstanceOfto check the exception cause chain. This handles both cases and provides better diagnostics (full stack trace) on failure:CamelExecutionException→ShutdownSignalExceptionCamelExecutionException→AmqpException→ShutdownSignalException