Croway commented on code in PR #2013:
URL: 
https://github.com/apache/camel-spring-boot/pull/2013#discussion_r4157825440


##########
dsl-starter/camel-cli-connector-starter/src/main/java/org/apache/camel/springboot/cli/connector/SpringLocalCliConnector.java:
##########
@@ -30,12 +32,27 @@ public SpringLocalCliConnector(CliConnectorFactory 
cliConnectorFactory,
         this.applicationContext = applicationContext;
     }
 
+    @Override
+    protected CliConnectorTransport createTransport(String name) {
+        // Camel refuses it with the Camel prod profile (camel.main.profile), 
which Spring profiles do not set
+        if ("websocket".equalsIgnoreCase(name)
+                && 
applicationContext.getEnvironment().acceptsProfiles(Profiles.of("prod"))) {
+            throw new IllegalStateException(
+                    "The Camel CLI connector websocket transport gives the 
connected tool full control of this"
+                                            + " application and cannot be used 
with the Spring prod profile."
+                                            + " Remove 
camel.cli.transport=websocket, or use another profile.");
+        }
+        return super.createTransport(name);
+    }
+
     @Override
     public void sigterm() {
         try {
             super.sigterm();
         } finally {
-            applicationContext.stop();
+            // close, not only stop: a stopped context keeps the JVM running 
(for example the embedded web server),
+            // while the Camel CLI (camel stop) and the websocket tools expect 
the application to exit
+            applicationContext.close();

Review Comment:
   _Claude Code on behalf of Croway_
   
   Done in 0a8cc3cefc3: a comment on the concurrent stop (Camel stops a context 
under a lock in `BaseService.stop()`, so whichever comes second waits for the 
first, then finds it stopped), and 
`CliConnectorSpringLifecycleTest.camelStopClosesTheApplicationContext` for the 
file transport (lock file deleted, context closed).



##########
dsl-starter/camel-cli-connector-starter/src/main/java/org/apache/camel/springboot/cli/connector/CliConnectorAutoConfiguration.java:
##########
@@ -69,4 +73,30 @@ public CliConnectorFactory 
cliConnectorFactory(AbstractApplicationContext applic
         return answer;
     }
 
+    /**
+     * The Spring WebSocket client for the websocket transport, when the 
application has spring-websocket and a Jakarta
+     * WebSocket client (such as Tomcat with spring-boot-starter-websocket). 
Otherwise Camel uses the JDK client.
+     */
+    @Configuration(proxyBeanMethods = false)
+    @ConditionalOnClass(name = {
+            
"org.springframework.web.socket.client.standard.StandardWebSocketClient",
+            "jakarta.websocket.ContainerProvider" })

Review Comment:
   _Claude Code on behalf of Croway_
   
   Done in 0a8cc3cefc3: `OnSpringWebSocketClientCondition` also requires a 
`ContainerProvider` service (looked up with `ServiceLoader` as 
`ContainerProvider.getWebSocketContainer()` does, without creating it), so the 
API alone no longer matches and Camel keeps the JDK client. Tested with a 
`FilteredClassLoader` hiding 
`META-INF/services/jakarta.websocket.ContainerProvider`.



##########
dsl-starter/camel-cli-connector-starter/src/test/java/org/apache/camel/springboot/cli/connector/CliConnectorWebSocketJdkClientTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.springboot.cli.connector;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit6.CamelSpringBootTest;
+import org.apache.camel.test.spring.junit6.DisableJmx;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+
+/**
+ * The connector uses the JDK client when asked to, even with the Spring 
WebSocket client available.
+ */
+@DirtiesContext
+@CamelSpringBootTest
+// the status sent to the tool is built from the JMX management layer
+@DisableJmx(false)
+@SpringBootTest(classes = {
+        CamelAutoConfiguration.class, CliConnectorAutoConfiguration.class,
+        CliConnectorWebSocketTestSupport.Routes.class },
+                properties = {
+                        "camel.cli.transport=websocket",
+                        "camel.cli.websocket.snapshot-interval=200",
+                 "camel.cli.websocket.client=jdk" })

Review Comment:
   _Claude Code on behalf of Croway_
   
   Fixed in 0a8cc3cefc3.



-- 
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]

Reply via email to