Fix infinispan example: create the missing default cache on startup - #201
Open
Croway wants to merge 1 commit into
Open
Fix infinispan example: create the missing default cache on startup#201Croway wants to merge 1 commit into
Croway wants to merge 1 commit into
Conversation
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
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
camel infra run infinispanonly provisions thedefaultcache-container on the Infinispan server, it does not create a cache inside it (confirmed unchanged since at least thecamel-4.22.0tag in apache/camel — not a recent regression). The example's route usesto("infinispan://default"), which assumes the cache already exists, so following the documented README workflow (camel infra run infinispan+mvn spring-boot:run) throwsCacheNotFoundException/NullPointerException. The test suite masked this by spinning up its own container with a hand-written, outdatedinfinispan.xml(schema 13.0) that predeclared the cache — so it never exercised the documented workflow and the regression went unnoticed.Separately, the plaintext
admin/passwordcredentials inapplication.propertiesnow triggerCamelSecurityPolicyAutoConfiguration"SECURITY WARNING: plain-text secret" warnings introduced in Camel 4.23.Changes
InfinispanConfiguration: aRemoteCacheManager@Beanthat callsadministration().getOrCreateCache("default", ...)on startup and is autowired into theinfinispancomponent by type — the same pattern camel-infinispan's own IT tests use (InfinispanRemoteTestSupport#getOrCreateCache). No manual REST step required; the example runs OOTB again.camel.component.infinispan.*(now unused/redundant, since the component uses the bean directly) into plaininfinispan.*properties backed by${ENV_VAR:default}placeholders. This also resolves the plaintext-secret warnings, sinceCamelSecurityPolicyAutoConfigurationonly scanscamel.*-prefixed keys.ApplicationTestto usecamel-test-infra-infinispan'sInfinispanServiceFactory+@DynamicPropertySourceinstead of a hand-rolled Testcontainers setup, so the test now exercises the exact same server config ascamel infra run infinispanand would catch this kind of regression.Test plan
mvn testpasses (spins up Infinispan viacamel-test-infra-infinispan, verifies the route puts/gets a key through the auto-created cache)camel infra run infinispan+mvn spring-boot:run— reproduced the originalCacheNotFoundException/NPE before the fix, confirmed clean startup andReceived body: testwith no exceptions and no security warnings after the fix🤖 Generated with Claude Code
https://claude.ai/code/session_01Wgr7MBBqUbNGG6xrH6ybWq