chore: fail with clear error when script EIP has empty expression body#23385
Merged
Conversation
When camel-xml-io-dsl parses a whitespace-only expression body (e.g., <groovy></groovy>), the expression text ends up as null. At runtime this causes an NPE in ConcurrentHashMap.get(null) deep in the language runtime. Add validation in ScriptReifier to detect null/empty script code early and throw a clear IllegalArgumentException instead. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
Contributor
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
Contributor
|
🧪 CI tested the following changed modules:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Claude Code on behalf of Claus Ibsen
When
camel-xml-io-dslparses a whitespace-only expression body (e.g.,<groovy>\n</groovy>), the expression text ends up asnull. At runtime,GroovyLanguage.getScriptFromCache(null)callsConcurrentHashMap.get(null), which throws an unhelpfulNullPointerException.This PR adds validation in
ScriptReifier.createProcessor()to detect null/empty script code early and throw a clearIllegalArgumentExceptionwith the message: "Script has no script code configured in ..."This is the intended behavior — an empty tag is regarded as null by
camel-xml-io-dsl(by design), but the NPE error message was confusing.Reported on Zulip: https://camel.zulipchat.com/#narrow/channel/257298-camel/topic/camel-xml-io.20drops.20whitespace-only.20expression.20bodies
Changes
core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ScriptReifier.java— Added null/empty check on the expression definition before creating the runtime expression and processorTest plan
mvn clean install -DskipTests)mvn formatter:format impsort:sort)<groovy></groovy>that the error message is clear instead of NPE🤖 Generated with Claude Code