Skip to content

CAMEL-23428: Fix flaky RabbitMQProducerInvalidExchangeIT test#22980

Merged
gnodet merged 2 commits intoapache:mainfrom
gnodet:CAMEL-23428-fix-flaky-rabbitmq-test
May 6, 2026
Merged

CAMEL-23428: Fix flaky RabbitMQProducerInvalidExchangeIT test#22980
gnodet merged 2 commits intoapache:mainfrom
gnodet:CAMEL-23428-fix-flaky-rabbitmq-test

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 6, 2026

CAMEL-23428

The RabbitMQProducerInvalidExchangeIT.testProducer test is flaky because it asserts the direct cause of CamelExecutionException is ShutdownSignalException. However, Spring AMQP may wrap the underlying ShutdownSignalException in an AmqpException depending on timing, causing intermittent failures.

Fix: Use AssertJ's hasRootCauseInstanceOf to check the exception cause chain. This handles both cases and provides better diagnostics (full stack trace) on failure:

  • Direct cause: CamelExecutionExceptionShutdownSignalException
  • Wrapped cause: CamelExecutionExceptionAmqpExceptionShutdownSignalException

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gnodet gnodet requested review from cunningt and oscerd May 6, 2026 04:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🧪 CI tested the following changed modules:

  • components/camel-spring-parent/camel-spring-rabbitmq

POM dependency changes: targeted tests included

Modules affected by dependency changes (1)
  • :camel-spring-rabbitmq
All tested modules (8 modules)
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container
  • Camel :: Spring RabbitMQ
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

Comment on lines +53 to +59
// 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());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@gnodet gnodet merged commit b4b8f10 into apache:main May 6, 2026
6 checks passed
@gnodet gnodet deleted the CAMEL-23428-fix-flaky-rabbitmq-test branch May 6, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants