gnodet commented on code in PR #31305:
URL: https://github.com/apache/camel/pull/31305#discussion_r4798478103
##########
components/camel-infinispan/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/remote/InfinispanRemoteAggregationRepository.java:
##########
@@ -110,6 +112,44 @@ protected void doStart() throws Exception {
ServiceHelper.startService(manager);
}
+ private void applyConnectionProperties(InfinispanRemoteConfiguration conf,
ConfigurationBuilder builder)
Review Comment:
**Code duplication:** This entire method (lines 115-150) duplicates the
connection properties logic from `InfinispanRemoteManager.doStart()` lines
87-127.
Recommend extracting this into a shared method to avoid maintenance issues -
a bug fix or enhancement to connection handling would need to be applied in two
places.
##########
components/camel-infinispan/camel-infinispan-embedded/src/main/java/org/apache/camel/component/infinispan/embedded/cluster/InfinispanEmbeddedClusterView.java:
##########
@@ -169,11 +170,13 @@ protected void doStart() throws Exception {
cache.addListener(this);
+ long periodMillis = Math.max(1,
Review Comment:
✅ Good fix for the integer division truncation issue. The `Math.max(1, ...)`
ensures the period is at least 1ms even for sub-second lifespans.
Minor concern: verify this doesn't create excessive overhead for very small
lifespans (e.g., lifespan=1ms would schedule every 0.5ms → clamped to 1ms).
Consider if a minimum period threshold is needed in practice.
##########
components/camel-infinispan/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/remote/InfinispanRemoteConfigurationTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.infinispan.remote;
+
+import java.util.concurrent.TimeUnit;
+
+import
org.apache.camel.component.infinispan.remote.cluster.InfinispanRemoteClusterConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class InfinispanRemoteConfigurationTest {
+
+ @Test
+ void clusterConfigurationDisablesEmbeddingStore() {
+ InfinispanRemoteClusterConfiguration config = new
InfinispanRemoteClusterConfiguration();
+
assertThat(config.getConfiguration().isEmbeddingStoreEnabled()).isFalse();
+ }
+
+ @Test
+ void managerRequiresHostsWhenNoCacheContainerOrConfiguration() {
+ InfinispanRemoteConfiguration conf = new
InfinispanRemoteConfiguration();
+ conf.setEmbeddingStoreEnabled(false);
+ InfinispanRemoteManager manager = new InfinispanRemoteManager(new
DefaultCamelContext(), conf);
+
+ assertThatThrownBy(manager::start)
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("hosts is required");
+ }
+
+ @Test
+ void aggregationRepositoryRequiresCredentialsWhenSecure() {
+ InfinispanRemoteConfiguration conf = new
InfinispanRemoteConfiguration();
+ conf.setHosts("localhost:11222");
+ conf.setSecure(true);
+ InfinispanRemoteAggregationRepository repository = new
InfinispanRemoteAggregationRepository("exchanges");
+ repository.setConfiguration(conf);
+ repository.setCamelContext(new DefaultCamelContext());
+
+ assertThatThrownBy(repository::start)
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("username and password are needed");
+ }
+
+ @Test
Review Comment:
These tests (lines 61-70) just verify `Math.max` arithmetic, not the actual
cluster view implementation.
Consider either:
1. Removing these trivial tests (they don't test real code paths), OR
2. Replacing them with integration tests that verify cluster view scheduling
actually works with `lifespan=1` and sub-second lifespans
##########
components/camel-infinispan/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/remote/InfinispanRemoteAggregationRepository.java:
##########
@@ -86,18 +89,17 @@ protected void doStart() throws Exception {
super.doStart();
InfinispanRemoteConfiguration conf = configuration != null ?
configuration : new InfinispanRemoteConfiguration();
-
- if (conf.getCacheContainerConfiguration() == null) {
- conf.setCacheContainerConfiguration(
- new ConfigurationBuilder()
- .addContextInitializer(new
DefaultExchangeHolderContextInitializer())
- .build());
- } else {
- conf.setCacheContainerConfiguration(
- new ConfigurationBuilder()
- .read(conf.getCacheContainerConfiguration(),
Combine.DEFAULT)
- .addContextInitializer(new
DefaultExchangeHolderContextInitializer())
- .build());
+ conf.setEmbeddingStoreEnabled(false);
Review Comment:
Setting `embeddingStoreEnabled=false` is done here, in the idempotent
repository's `doStart()`, in the key-value repository's `doStart()`, and in the
cluster configuration constructor.
For consistency, consider setting this as a default in
`InfinispanRemoteConfiguration` itself or only in the places where it's truly
needed.
##########
components/camel-infinispan/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/remote/InfinispanRemoteManager.java:
##########
@@ -84,6 +84,10 @@ public void doStart() throws Exception {
// If the hosts properties has been configured, it means we want to
// connect to a remote cache so set-up a RemoteCacheManager
if (cacheContainer == null) {
+ if (ObjectHelper.isEmpty(configuration.getHosts())) {
Review Comment:
Good validation, but consider whether the error message should be more
specific: "At least one of cacheContainer, cacheContainerConfiguration, or
hosts must be configured"
##########
components/camel-infinispan/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/remote/InfinispanRemoteConfigurationTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.infinispan.remote;
+
+import java.util.concurrent.TimeUnit;
+
+import
org.apache.camel.component.infinispan.remote.cluster.InfinispanRemoteClusterConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class InfinispanRemoteConfigurationTest {
+
+ @Test
+ void clusterConfigurationDisablesEmbeddingStore() {
+ InfinispanRemoteClusterConfiguration config = new
InfinispanRemoteClusterConfiguration();
+
assertThat(config.getConfiguration().isEmbeddingStoreEnabled()).isFalse();
+ }
+
+ @Test
Review Comment:
**Test coverage gap:** This test only verifies the error case. Add a
positive test that when `cacheContainerConfiguration` IS set, hosts are NOT
required:
```java
@Test
void managerDoesNotRequireHostsWhenCacheContainerConfigurationIsSet() throws
Exception {
InfinispanRemoteConfiguration conf = new InfinispanRemoteConfiguration();
conf.setEmbeddingStoreEnabled(false);
conf.setCacheContainerConfiguration(new ConfigurationBuilder().build());
InfinispanRemoteManager manager = new InfinispanRemoteManager(new
DefaultCamelContext(), conf);
assertThatCode(manager::start).doesNotThrowAnyException();
manager.stop();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]