Skip to content

registering common Camel types used in onException for refle…#8505

Merged
aldettinger merged 1 commit intoapache:mainfrom
JinyuChen97:camel-quarkus-7608
Apr 10, 2026
Merged

registering common Camel types used in onException for refle…#8505
aldettinger merged 1 commit intoapache:mainfrom
JinyuChen97:camel-quarkus-7608

Conversation

@JinyuChen97
Copy link
Copy Markdown
Contributor

@JinyuChen97 JinyuChen97 commented Apr 7, 2026

fixes #7608

Found several common Camel exceptions that are frequently used in onException() handlers across multiple extensions. These are now registered centrally in camel-quarkus-core to avoid duplication and prevent ClassNotFoundException in native mode.

  1. ExchangeTimedOutException
  2. CamelAuthorizationException
  3. CamelExecutionException
  4. ThrottlerRejectedExecutionException

@aldettinger
Copy link
Copy Markdown
Contributor

There is a question whether integration-tests/netty is the right place for such a test ? Maybe something ala foundation/on-exception would be better ?

It would be good to have other advice here.

@zhfeng
Copy link
Copy Markdown
Contributor

zhfeng commented Apr 9, 2026

Sorry @JinyuChen97 , I merge the following PR and it could conflict with your changes.

@jamesnetherton
Copy link
Copy Markdown
Contributor

Sorry @JinyuChen97 , I merge the following PR and it could conflict with your changes.

Yeah I think #8508 mostly supersedes this. What we could do instead in this PR, is search the codebase for usages of:

ExchangeTimedOutException
CamelAuthorizationException
CamelExecutionException
ThrottlerRejectedExecutionException

And remove any native reflection configuration and verify that the native tests continue to pass.

@JinyuChen97
Copy link
Copy Markdown
Contributor Author

Sorry @JinyuChen97 , I merge the following PR and it could conflict with your changes.

Yeah I think #8508 mostly supersedes this. What we could do instead in this PR, is search the codebase for usages of:

ExchangeTimedOutException CamelAuthorizationException CamelExecutionException ThrottlerRejectedExecutionException

And remove any native reflection configuration and verify that the native tests continue to pass.

Verified exception class registration using onException test. All exceptions are now auto-registered by the code change from #8508. The onException test handlers were removed after verification.
Only found one manually registered exception 'CamelAuthorizationException' in ShiroProcessor.java, which has been removed.

@aldettinger
Copy link
Copy Markdown
Contributor

Don't we have more to cover like in MllpRoutes.java where we have @RegisterForReflection(targets = MllpInvalidMessageException.class, fields = false) ? If yes, could it make sense to modify the prompt to spot those cases ?

@JinyuChen97
Copy link
Copy Markdown
Contributor Author

Don't we have more to cover like in MllpRoutes.java where we have @RegisterForReflection(targets = MllpInvalidMessageException.class, fields = false) ? If yes, could it make sense to modify the prompt to spot those cases ?

oh yes, you are right, this exception is used by onException(class) pattern, so it can be removed as well.
I also found other exceptions annotated with @RegisterForReflection, but they are used by throwException(new xxxexception()) and they are not abled to be detected by the CamelNativeImageProcessor.

integration-tests/servlet/src/main/java/org/apache/camel/quarkus/component/servlet/CustomException.java
annotation: @RegisterForReflection
usage: throwException(new CustomException())

integration-test-groups/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpRoutes.java
annotation: @RegisterForReflection(targets = IllegalStateException.class, serialization = true)
usage: throwException(new IllegalStateException("Forced exception"))

integration-tests-support/messaging/common/src/main/java/org/apache/camel/quarkus/component/messaging/it/MessagingCommonRoutes.java
annotation: @RegisterForReflection(targets = IllegalStateException.class, serialization = true)
usage: throw new IllegalStateException(...)

please suggest if you found more. And should we investigate the solution of adding throwException(new class) or leave them at the moment?

@aldettinger
Copy link
Copy Markdown
Contributor

Yes, there are probably more, a general review is probably needed. And maybe we could have in other DSLs, like xml dsl. Concerning throwException, it might be out of scope of this pr, maybe it could be separated to another ticket.

@zhfeng
Copy link
Copy Markdown
Contributor

zhfeng commented Apr 9, 2026 via email

@JinyuChen97
Copy link
Copy Markdown
Contributor Author

Well, I think throwException is supported as well. Alexandre Gallice @.> 于2026年4月9日周四 22:39写道:

aldettinger left a comment (apache/camel-quarkus#8505) <#8505 (comment)> Yes, there are probably more, a general review is probably needed. And maybe we could have in other DSLs, like xml dsl. Concerning throwException, it might be out of scope of this pr, maybe it could be separated to another ticket. — Reply to this email directly, view it on GitHub <#8505 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJQHOYOK4F3T6H4V6YLBG34U6YYTAVCNFSM6AAAAACXPN7BQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DEMJVGA4TONJVGU . You are receiving this because you were mentioned.Message ID: @.
>

throwException(Class) is supported, but the way like throwException(new instance) seems not supported , please correct me if i'm wrong.

@zhfeng
Copy link
Copy Markdown
Contributor

zhfeng commented Apr 9, 2026 via email

@aldettinger
Copy link
Copy Markdown
Contributor

aldettinger commented Apr 9, 2026

Yes, that could be the scope of another ticket, created #8512. Thanks all for great collective work on this subject 👍

@jamesnetherton
Copy link
Copy Markdown
Contributor

@aldettinger is this good to merge?

@aldettinger
Copy link
Copy Markdown
Contributor

Not sure yet.

What about src/main/java/org/apache/camel/quarkus/eip/it/EipRoutes.java with @RegisterForReflection(targets = ThrottlerRejectedExecutionException.class) ?

@jamesnetherton
Copy link
Copy Markdown
Contributor

Not sure yet.

What about src/main/java/org/apache/camel/quarkus/eip/it/EipRoutes.java with @RegisterForReflection(targets = ThrottlerRejectedExecutionException.class) ?

Seems that was taken care of in 76f2ba2.

@aldettinger
Copy link
Copy Markdown
Contributor

And a last one is ./integration-tests/main-yaml/src/main/java/org/apache/camel/quarkus/main/CustomException.java.

This one is also used to test throwException by class but not not throwException by instance... So maybe it is a candidate for removal ?

@JinyuChen97
Copy link
Copy Markdown
Contributor Author

And a last one is ./integration-tests/main-yaml/src/main/java/org/apache/camel/quarkus/main/CustomException.java.

This one is also used to test throwException by class but not not throwException by instance... So maybe it is a candidate for removal ?

hmmm, I think I have removed it? (The main-yaml/CustomException in the change) it's the one used in yaml dsl.

@aldettinger
Copy link
Copy Markdown
Contributor

@JinyuChen97 It's right, things were mixed up on my machine. Sorry, for the noise.

@aldettinger aldettinger merged commit cbb2634 into apache:main Apr 10, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider registering common Camel types used in onException for reflection

4 participants