This is an automated email from the ASF dual-hosted git repository.

apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 02956e555657 Close InfraTest service with try-with-resource
02956e555657 is described below

commit 02956e555657dc3e8c7b251aac376dd5ea8b74c3
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Fri Feb 27 15:00:40 2026 +0100

    Close InfraTest service with try-with-resource
    
    reported as blocker for reliability on new code
    
https://sonarcloud.io/project/issues?impactSeverities=BLOCKER&sinceLeakPeriod=true&issueStatuses=OPEN%2CCONFIRMED&id=apache_camel&open=AZyNjBgSRI2J376LdKGM
    
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../test/infra/docling/DoclingInfraServiceTest.java | 14 ++++++--------
 .../infra/keycloak/KeycloakInfraServiceTest.java    | 21 ++++++++++-----------
 2 files changed, 16 insertions(+), 19 deletions(-)

diff --git 
a/test-infra/camel-test-infra-docling/src/main/java/org/apache/camel/test/infra/docling/DoclingInfraServiceTest.java
 
b/test-infra/camel-test-infra-docling/src/main/java/org/apache/camel/test/infra/docling/DoclingInfraServiceTest.java
index 2a093a578b9f..4718031e5aba 100644
--- 
a/test-infra/camel-test-infra-docling/src/main/java/org/apache/camel/test/infra/docling/DoclingInfraServiceTest.java
+++ 
b/test-infra/camel-test-infra-docling/src/main/java/org/apache/camel/test/infra/docling/DoclingInfraServiceTest.java
@@ -25,19 +25,17 @@ import static org.junit.jupiter.api.Assertions.*;
 public class DoclingInfraServiceTest {
 
     @Test
-    public void testRemoteServiceConfiguration() {
-        DoclingInfraService service = new 
DoclingRemoteInfraService("http://localhost:5001";);
-
-        assertEquals("http://localhost:5001";, service.doclingServerUrl());
+    public void testRemoteServiceConfiguration() throws Exception {
+        try (DoclingInfraService service = new 
DoclingRemoteInfraService("http://localhost:5001";)) {
+            assertEquals("http://localhost:5001";, service.doclingServerUrl());
+        }
     }
 
     @Test
-    public void testRemoteServiceWithSystemProperties() {
+    public void testRemoteServiceWithSystemProperties() throws Exception {
         System.setProperty("docling.server.url", "http://test:5001";);
 
-        try {
-            DoclingInfraService service = new DoclingRemoteInfraService();
-
+        try (DoclingInfraService service = new DoclingRemoteInfraService()) {
             assertEquals("http://test:5001";, service.doclingServerUrl());
         } finally {
             System.clearProperty("docling.server.url");
diff --git 
a/test-infra/camel-test-infra-keycloak/src/main/java/org/apache/camel/test/infra/keycloak/KeycloakInfraServiceTest.java
 
b/test-infra/camel-test-infra-keycloak/src/main/java/org/apache/camel/test/infra/keycloak/KeycloakInfraServiceTest.java
index 04d7174b7298..a528a1cc0de9 100644
--- 
a/test-infra/camel-test-infra-keycloak/src/main/java/org/apache/camel/test/infra/keycloak/KeycloakInfraServiceTest.java
+++ 
b/test-infra/camel-test-infra-keycloak/src/main/java/org/apache/camel/test/infra/keycloak/KeycloakInfraServiceTest.java
@@ -25,29 +25,28 @@ import static org.junit.jupiter.api.Assertions.*;
 public class KeycloakInfraServiceTest {
 
     @Test
-    public void testRemoteServiceConfiguration() {
-        KeycloakInfraService service = new KeycloakRemoteInfraService(
+    public void testRemoteServiceConfiguration() throws Exception {
+        try (KeycloakInfraService service = new KeycloakRemoteInfraService(
                 "http://localhost:8080";,
                 "master",
                 "admin",
-                "admin");
+                "admin")) {
 
-        assertEquals("http://localhost:8080";, service.getKeycloakServerUrl());
-        assertEquals("master", service.getKeycloakRealm());
-        assertEquals("admin", service.getKeycloakUsername());
-        assertEquals("admin", service.getKeycloakPassword());
+            assertEquals("http://localhost:8080";, 
service.getKeycloakServerUrl());
+            assertEquals("master", service.getKeycloakRealm());
+            assertEquals("admin", service.getKeycloakUsername());
+            assertEquals("admin", service.getKeycloakPassword());
+        }
     }
 
     @Test
-    public void testRemoteServiceWithSystemProperties() {
+    public void testRemoteServiceWithSystemProperties() throws Exception {
         System.setProperty("keycloak.server.url", "http://test:8080";);
         System.setProperty("keycloak.realm", "test");
         System.setProperty("keycloak.username", "testuser");
         System.setProperty("keycloak.password", "testpass");
 
-        try {
-            KeycloakInfraService service = new KeycloakRemoteInfraService();
-
+        try (KeycloakInfraService service = new KeycloakRemoteInfraService()) {
             assertEquals("http://test:8080";, service.getKeycloakServerUrl());
             assertEquals("test", service.getKeycloakRealm());
             assertEquals("testuser", service.getKeycloakUsername());

Reply via email to