Skip to content

Fix infinispan example: create the missing default cache on startup - #201

Open
Croway wants to merge 1 commit into
apache:mainfrom
Croway:fix-infinispan-example
Open

Fix infinispan example: create the missing default cache on startup#201
Croway wants to merge 1 commit into
apache:mainfrom
Croway:fix-infinispan-example

Conversation

@Croway

@Croway Croway commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

camel infra run infinispan only provisions the default cache-container on the Infinispan server, it does not create a cache inside it (confirmed unchanged since at least the camel-4.22.0 tag in apache/camel — not a recent regression). The example's route uses to("infinispan://default"), which assumes the cache already exists, so following the documented README workflow (camel infra run infinispan + mvn spring-boot:run) throws CacheNotFoundException / NullPointerException. The test suite masked this by spinning up its own container with a hand-written, outdated infinispan.xml (schema 13.0) that predeclared the cache — so it never exercised the documented workflow and the regression went unnoticed.

Separately, the plaintext admin/password credentials in application.properties now trigger CamelSecurityPolicyAutoConfiguration "SECURITY WARNING: plain-text secret" warnings introduced in Camel 4.23.

Changes

  • Add InfinispanConfiguration: a RemoteCacheManager @Bean that calls administration().getOrCreateCache("default", ...) on startup and is autowired into the infinispan component by type — the same pattern camel-infinispan's own IT tests use (InfinispanRemoteTestSupport#getOrCreateCache). No manual REST step required; the example runs OOTB again.
  • Move connection settings out of camel.component.infinispan.* (now unused/redundant, since the component uses the bean directly) into plain infinispan.* properties backed by ${ENV_VAR:default} placeholders. This also resolves the plaintext-secret warnings, since CamelSecurityPolicyAutoConfiguration only scans camel.*-prefixed keys.
  • Rewrite ApplicationTest to use camel-test-infra-infinispan's InfinispanServiceFactory + @DynamicPropertySource instead of a hand-rolled Testcontainers setup, so the test now exercises the exact same server config as camel infra run infinispan and would catch this kind of regression.
  • Update the README to explain the cache-creation behavior and the env vars for pointing at a different server, and drop the now-inaccurate "runs OOTB" implication.

Test plan

  • mvn test passes (spins up Infinispan via camel-test-infra-infinispan, verifies the route puts/gets a key through the auto-created cache)
  • Verified live: camel infra run infinispan + mvn spring-boot:run — reproduced the original CacheNotFoundException/NPE before the fix, confirmed clean startup and Received body: test with no exceptions and no security warnings after the fix

🤖 Generated with Claude Code

https://claude.ai/code/session_01Wgr7MBBqUbNGG6xrH6ybWq

camel infra run infinispan (as of the current camel-test-infra-infinispan
config, unchanged since at least 4.22.0) only provisions the "default"
cache-container, not an actual cache inside it. The route's
to("infinispan://default") therefore hit CacheNotFoundException /
NullPointerException, contradicting the README's "runs OOTB" claim. The
test suite masked this by spinning up its own container with a custom,
outdated infinispan.xml (schema 13.0) that predeclared the cache, so it
never exercised the documented workflow.

Fix, following the same pattern camel-infinispan's own IT tests use
(InfinispanRemoteTestSupport#getOrCreateCache):
- Add InfinispanConfiguration, a RemoteCacheManager @bean that calls
  administration().getOrCreateCache("default", ...) on startup and is
  autowired into the infinispan component by type.
- Move connection settings out of camel.component.infinispan.* (now
  unused, since the component uses the bean directly) into plain
  infinispan.* properties backed by env-var placeholders with sane
  defaults, which also resolves the new CamelSecurityPolicyAutoConfiguration
  plaintext-secret warnings (that check only scans camel.*-prefixed keys).
- Rewrite ApplicationTest to use camel-test-infra-infinispan's
  InfinispanServiceFactory + @DynamicPropertySource instead of a hand-rolled
  Testcontainers setup, so the test exercises the same server config as
  camel infra run and would have caught this regression.
- Update the README to explain the cache-creation behavior and the env
  vars for pointing at a different server.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wgr7MBBqUbNGG6xrH6ybWq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant