Skip to content

chore: fail with clear error when script EIP has empty expression body#23385

Merged
davsclaus merged 1 commit into
mainfrom
quick-fix/script-eip-empty-expression-npe
May 20, 2026
Merged

chore: fail with clear error when script EIP has empty expression body#23385
davsclaus merged 1 commit into
mainfrom
quick-fix/script-eip-empty-expression-npe

Conversation

@davsclaus
Copy link
Copy Markdown
Contributor

Summary

Claude Code on behalf of Claus Ibsen

When camel-xml-io-dsl parses a whitespace-only expression body (e.g., <groovy>\n</groovy>), the expression text ends up as null. At runtime, GroovyLanguage.getScriptFromCache(null) calls ConcurrentHashMap.get(null), which throws an unhelpful NullPointerException.

This PR adds validation in ScriptReifier.createProcessor() to detect null/empty script code early and throw a clear IllegalArgumentException with 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 processor

Test plan

  • Full reactor build passes (mvn clean install -DskipTests)
  • Code formatting verified (mvn formatter:format impsort:sort)
  • Verify with a route containing <groovy></groovy> that the error message is clear instead of NPE

🤖 Generated with Claude Code

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>
@github-actions
Copy link
Copy Markdown
Contributor

ghost commented May 20, 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.

@davsclaus davsclaus merged commit 6b95cab into main May 20, 2026
6 checks passed
@davsclaus davsclaus deleted the quick-fix/script-eip-empty-expression-npe branch May 20, 2026 18:39
@github-actions
Copy link
Copy Markdown
Contributor

ghost commented May 20, 2026

🧪 CI tested the following changed modules:

  • core/camel-core-reifier

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.


⚙️ View full build and test results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant