Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camel Quarkus 3.19.0/Quarkus 3.19.1 ignores empty body in .when() statement #7085

Open
janwesterkamp opened this issue Mar 4, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@janwesterkamp
Copy link

Bug description

I am using the choice/when statements to do input validation and sometimes there are no statements inside.
After switching Quarkus version 3.18.4 to 3.19.1 (which includes Camel Quarkus 3.19.0), these empty checks are ignored, which causes a breaking change.
I found a workaround for this by adding something like a .log() statement - then it will be validated again.

However, I thing this is a bug that needs to be fixed.

Here is some example route to show the issue:

//FIXME
from("direct:test")
  //TODO Set this to "2" for the workaround
  .setHeader("test", constant("1"))
  .choice()
      .when(header("test").isEqualTo("1"))
         //Empty - fails on Quarkus version 3.19.1
      .when(header("test").isEqualTo("2"))
          //FIXME Workaround for Quarkus version 3.19.1 - empty when body causes issue!
          .log(LoggingLevel.INFO, "Processing test=${header.test}")
       .otherwise()
          .throwException(new RuntimeException("Vaildation error!"))
   .end()
;

May be the latest changes regarding .when() statements causing this as an side effect?

@janwesterkamp janwesterkamp added the bug Something isn't working label Mar 4, 2025
@jamesnetherton
Copy link
Contributor

I guess something changed between Camel 4.9.x and 4.10.x. @davsclaus WDYT?

@davsclaus
Copy link
Contributor

you cannot have empty when's so old code was wrong

@janwesterkamp
Copy link
Author

Why not? Do I have to add senseless statements only to fulfil your requirement, @davsclaus ?

It was possible to do in 3.18.4, so 3.19.1 is introducing a breaking change here.

Here my use case: I am checking a positive list of values with these statements and the .otherwhise() statement will catch all other values and breaks further processing (failing fast). I started this originally because the REST DSL had some limitations in input validation (might become better now), but now it's used for more complex checks too.. The validated values are further processed later in other routes (where the .when() statements contain actions).

In my eyes, this is an valid use case and empty when() should be allowed in newer versions.

@davsclaus
Copy link
Contributor

Okay there is a bug that the otherwise block is calling when no outputs.
https://issues.apache.org/jira/browse/CAMEL-21832

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants