Skip to content

CAMEL-22894: Extract jq/jsonpath/xpath/simpleJsonpath Simple functions into QueryLanguageFunctionFactory#23566

Merged
davsclaus merged 1 commit into
apache:mainfrom
ammachado:CAMEL-22894
May 27, 2026
Merged

CAMEL-22894: Extract jq/jsonpath/xpath/simpleJsonpath Simple functions into QueryLanguageFunctionFactory#23566
davsclaus merged 1 commit into
apache:mainfrom
ammachado:CAMEL-22894

Conversation

@ammachado
Copy link
Copy Markdown
Contributor

Description

Continues the CAMEL-22894 series of SimpleFunctionExpression refactoring.

This PR extracts the four embedded-language functions (jq, jsonpath, xpath, simpleJsonpath) that previously lived inline in SimpleFunctionExpression.createSimpleCustomLanguage() into a new dedicated QueryLanguageFunctionFactory. The factory is registered in SimpleFunctionDispatcher.BUILT_INS alongside the factories introduced in the prior PRs (#23263, #23382, #23388, #23432, #23445, #23544).

Also fixes a minor dead-code issue noted in the #23544 review: PropertiesFunctionFactory.createCode() had a parts.length > 2 guard that can never be true because the preceding split(":", 2) call limits the result to at most 2 elements.

SimpleFunctionExpression is now ~664 lines, down from the original 3,713.

Claude Code on behalf of Adriano Machado

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

…s into QueryLanguageFunctionFactory

Also drops the dead parts.length > 2 guard in PropertiesFunctionFactory.createCode()
noted in the PR apache#23544 review (split with limit 2 can never exceed 2 elements).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
@ammachado ammachado marked this pull request as ready for review May 27, 2026 14:25
@github-actions github-actions Bot added the core label May 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🌟 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

🧪 CI tested the following changed modules:

  • core/camel-core-languages
  • core/camel-core

ℹ️ 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.

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • core/camel-core: 2 test(s) disabled on GitHub Actions
Build reactor — dependencies compiled but only changed modules were tested (2 modules)
  • Camel :: Core
  • Camel :: Core Languages

⚙️ View full build and test results

Copy link
Copy Markdown
Contributor

@davsclaus davsclaus left a comment

Choose a reason for hiding this comment

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

Clean, well-executed continuation of the CAMEL-22894 refactoring series. Verified behavioral equivalence of the extracted QueryLanguageFunctionFactory against the removed createSimpleCustomLanguage() method — logic, error messages, and the distinct simpleJsonpath handling are all preserved.

The ordering change (query language functions now resolve via SimpleFunctionDispatcher.tryCreateBuiltIn() instead of a dedicated call earlier in doCreateSimpleExpression) is safe — no intermediate handler matches jq(/jsonpath(/xpath(/simpleJsonpath( prefixes.

The dead-code removal in PropertiesFunctionFactory.createCode() is correct (split(":", 2) guarantees at most 2 elements).

Tests cover xpath evaluation, expression creation for languages not on the core classpath, error cases, and createCode returning null. Existing integration tests in SimpleTest (lines 3812–3833) exercise simpleJsonpath end-to-end.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

@davsclaus davsclaus merged commit 03a8eb8 into apache:main May 27, 2026
6 checks passed
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.

2 participants