Skip to content

CAMEL-24623: camel-infinispan - report a QUERY that has no query builder - #26111

Open
oscerd wants to merge 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24623
Open

CAMEL-24623: camel-infinispan - report a QUERY that has no query builder#26111
oscerd wants to merge 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24623

Conversation

@oscerd

@oscerd oscerd commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Found by a source audit of components/camel-infinispan.

The problem

Both producers run the QUERY operation through an unguarded if:

final Query<?> query = InfinispanRemoteUtil.buildQuery(getConfiguration(), cache, message);

if (query != null) {
    setResult(message, query.execute().list());
}

and buildQuery returns null when neither the queryBuilder endpoint option nor the
CamelInfinispanQueryBuilder header is set. A route running operation=QUERY without a builder therefore
gets its own message back — no result, no exception, no log line — which is indistinguishable from a query
that legitimately matched nothing.

The change

The pass-through is kept. producerQueryOperationWithoutQueryBuilder has asserted "no exception, no
result" since the operation was contributed in CAMEL-9624 (2016), and the same test exists on the embedded
side, so failing the exchange would revert a deliberate, decade-old contract and would need an
upgrade-guide entry — disproportionate for what is a route misconfiguration.

What changes is only the silence:

  • both producers log a WARN naming the cache, the queryBuilder option and the CamelInfinispanQueryBuilder
    header;
  • the builder is resolved before the cache is looked up, so a misconfigured remote route no longer pays a
    Hot Rod round trip to do nothing;
  • InfinispanEmbeddedProducer.onQuery carried the identical defect — the audit only cited the remote one —
    and is fixed the same way.

If you would rather have it throw, that is a one-line change plus those two tests and an upgrade note; say
so and I will follow up.

Tests

InfinispanRemoteProducerQueryTest (new, 4 tests): the pass-through still happens and reaches no cache (the
manager it runs against was never started, so any remote call would fail), and the header-vs-option
precedence of the builder, which had no coverage at all.

mvn test on both modules is green — 89 embedded tests, including the 2016 producerQueryOperationWithoutQueryBuilder
against a real embedded cache, and 13 remote ones. Full reactor mvn clean install -DskipTests -Dquickly green.


Claude Code on behalf of oscerd

🤖 Generated with Claude Code

Both producers ran the QUERY operation through an "if (query != null)" with no
else branch, and buildQuery returns null when neither the queryBuilder option
nor the CamelInfinispanQueryBuilder header is set. A misconfigured route got its
own message back with no result, no exception and no log line, which is
indistinguishable from a query that matched nothing.

The pass-through is kept - it has been asserted by
producerQueryOperationWithoutQueryBuilder since the operation was contributed in
CAMEL-9624 - but it is now logged at WARN, naming the cache, the queryBuilder
option and the header. The builder is also resolved before the cache is looked
up, so a misconfigured remote route no longer pays a Hot Rod round trip to do
nothing.

The embedded producer carried the same defect and is fixed the same way.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JpshGTyfSmdq7hC8tuEwrZ
@oscerd
oscerd requested a review from davsclaus September 4, 2026 08:27
@oscerd oscerd added the bug Something isn't working label Sep 4, 2026
@oscerd
oscerd requested a review from gnodet September 4, 2026 08:27
@github-actions

github-actions Bot commented Sep 4, 2026

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.

@gnodet gnodet added port/camel-4.22.x Bug needs porting to camel-4.22.x port/camel-4.18.x Bug needs porting to camel-4.18.x labels Sep 4, 2026
@gnodet

gnodet commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🔄 Backport Bot

This bugfix targets main and may need porting to:

  • camel-4.22.x
  • camel-4.18.x

Labels port/<branch> have been added. Remove a label to opt out of porting to that branch.

Port PRs will be created automatically when this PR is merged. Comment /port to create them now.

ℹ️ If you push additional commits after /port, use /port again to update the port PRs.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-infinispan/camel-infinispan-embedded
  • components/camel-infinispan/camel-infinispan

🔬 Scalpel shadow comparison — Scalpel: 12 tested, 27 compile-only — current: 12 all tested

Maveniverse Scalpel detected 39 affected modules (current approach: 12).

⚠️ Modules only in Scalpel (27)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 12 modules (2 direct + 10 downstream), skip tests for 27 (generated code, meta-modules)

Modules Scalpel would test (12)
  • camel-infinispan
  • camel-infinispan-embedded
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-langchain4j-embeddings
  • camel-langchain4j-embeddingstore
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (27)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

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

  • components/camel-infinispan/camel-infinispan: 2 test(s) disabled on GitHub Actions
All tested modules (39 modules)
  • Camel :: AI :: LangChain4j :: Embedding
  • Camel :: AI :: LangChain4j :: EmbeddingStore
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Infinispan :: Embedded
  • Camel :: Infinispan :: Remote
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review summary: Solid, well-motivated fix. The refactoring correctly extracts builder resolution ahead of the cache lookup, preserving the decade-old pass-through contract while adding a useful WARN log. The InfinispanVectorQueryBuilder special handling is properly preserved. Tests cover the key resolution paths.

Two minor observations below.

Metadata: No milestone set — consider assigning to the appropriate release milestone.

This review was generated by an AI agent, Hermès, on behalf of @gnodet.

warnNoQueryBuilder();
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[low] After the builder != null check on line 58, buildQuery(builder, cache) delegates to queryBuilder != null ? queryBuilder.build(cache) : null — the null branch is dead code since we already filtered out null builders. If build() can genuinely return null, the warning message here is misleading: it says "Set a query builder" when the builder IS set but its build() produced no query.

Two options:

  1. Remove the second null check entirely (trust that build() returns non-null) and call setResult unconditionally after buildQuery.
  2. Keep the defensive check but use a different message, e.g. "Query builder returned no query for cache {}".

Same applies to the embedded producer.

return;
}

setResult(message, query.execute().list());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[low] warnNoQueryBuilder() is duplicated verbatim in InfinispanEmbeddedProducer. Since both producers extend InfinispanProducer, this method could live in the parent class to avoid the duplication.

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

Labels

bug Something isn't working components port/camel-4.18.x Bug needs porting to camel-4.18.x port/camel-4.22.x Bug needs porting to camel-4.22.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants