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

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

commit 122fe46b857dfc9ccffbd3f78fa1c5f5199a65d2
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Thu Nov 30 14:54:33 2023 -0300

    (chores) use simpler methods for emptiness checks
---
 .../src/main/java/org/apache/camel/http/common/HttpHelper.java        | 2 +-
 .../java/org/apache/camel/component/jetty/JettyHttpComponent.java     | 2 +-
 .../java/org/apache/camel/component/jetty11/JettyHttpComponent11.java | 2 +-
 .../java/org/apache/camel/component/jetty/HttpClientRouteTest.java    | 4 ++--
 .../src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java | 3 ++-
 .../java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java    | 3 ++-
 .../test/java/org/apache/camel/component/jetty/HttpsRouteTest.java    | 3 ++-
 .../java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java   | 3 ++-
 .../camel/component/netty/http/SecurityAuthenticatorSupport.java      | 4 ++--
 .../org/apache/camel/component/platform/http/main/MainHttpServer.java | 4 ++--
 .../component/platform/http/JettyCustomPlatformHttpConsumer.java      | 2 +-
 .../main/java/org/apache/camel/component/undertow/UndertowHelper.java | 2 +-
 .../camel/component/undertow/rest/RestUndertowHttpPojoTypeTest.java   | 2 +-
 .../java/org/apache/camel/component/vertx/http/VertxHttpHelper.java   | 2 +-
 14 files changed, 21 insertions(+), 17 deletions(-)

diff --git 
a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
 
b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
index b850b3627ed..4455b9fa1a1 100644
--- 
a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
+++ 
b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
@@ -204,7 +204,7 @@ public final class HttpHelper {
             if (path.length() > 1 && path.startsWith("/")) {
                 path = path.substring(1);
             }
-            if (path.length() > 0) {
+            if (!path.isEmpty()) {
                 // inject the dynamic path before the query params, if there 
are any
                 int idx = uri.indexOf('?');
 
diff --git 
a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
 
b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 27070b9bfec..3f306a172f4 100644
--- 
a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ 
b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -1348,7 +1348,7 @@ public abstract class JettyHttpComponent extends 
HttpCommonComponent
     @Override
     protected void doStop() throws Exception {
         super.doStop();
-        if (CONNECTORS.size() > 0) {
+        if (!CONNECTORS.isEmpty()) {
             for (Map.Entry<String, ConnectorRef> connectorEntry : 
CONNECTORS.entrySet()) {
                 ConnectorRef connectorRef = connectorEntry.getValue();
                 if (connectorRef != null && connectorRef.getRefCount() == 0) {
diff --git 
a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty11/JettyHttpComponent11.java
 
b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty11/JettyHttpComponent11.java
index 31dbf1a63a6..44fbbed8669 100644
--- 
a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty11/JettyHttpComponent11.java
+++ 
b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty11/JettyHttpComponent11.java
@@ -104,7 +104,7 @@ public class JettyHttpComponent11 extends 
JettyHttpComponent {
                     // must copy the map otherwise it will be deleted
                     Map<String, Object> properties = new 
HashMap<>(getSslSocketConnectorProperties());
                     PropertyBindingSupport.bindProperties(getCamelContext(), 
sslcf, properties);
-                    if (properties.size() > 0) {
+                    if (!properties.isEmpty()) {
                         throw new IllegalArgumentException(
                                 "There are " + properties.size() + " 
parameters that couldn't be set on the SocketConnector."
                                                            + " Check the uri 
if the parameters are spelt correctly and that they are properties of the 
SelectChannelConnector."
diff --git 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpClientRouteTest.java
 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpClientRouteTest.java
index 978f5b45cd3..d60df31c2f6 100644
--- 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpClientRouteTest.java
+++ 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpClientRouteTest.java
@@ -31,8 +31,8 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class HttpClientRouteTest extends BaseJettyTest {
 
@@ -69,7 +69,7 @@ public class HttpClientRouteTest extends BaseJettyTest {
 
         LOG.info("Headers: {}", headers);
 
-        assertTrue(headers.size() > 0, "Should be more than one header but 
was: " + headers);
+        assertFalse(headers.isEmpty(), "Should be more than one header but 
was: " + headers);
     }
 
     @Test
diff --git 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
index 15aa3e2f8ec..0f43737c4ca 100644
--- 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
+++ 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
@@ -47,6 +47,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -83,7 +84,7 @@ public class HttpRouteTest extends BaseJettyTest {
 
         LOG.info("Headers: {}", headers);
 
-        assertTrue(headers.size() > 0, "Should be more than one header but 
was: " + headers);
+        assertFalse(headers.isEmpty(), "Should be more than one header but 
was: " + headers);
     }
 
     @Test
diff --git 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
index d8873fb81f0..ffe77718803 100644
--- 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
+++ 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.camel.component.jetty.BaseJettyTest.SSL_SYSPROPS;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
@@ -116,7 +117,7 @@ public class HttpsAsyncRouteTest extends HttpsRouteTest {
 
         LOG.info("Headers: {}", headers);
 
-        assertTrue(headers.size() > 0, "Should be more than one header but 
was: " + headers);
+        assertFalse(headers.isEmpty(), "Should be more than one header but 
was: " + headers);
     }
 
     @Override
diff --git 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
index 26883ba31cc..f819568baa7 100644
--- 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
+++ 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
@@ -50,6 +50,7 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.camel.component.jetty.BaseJettyTest.SSL_SYSPROPS;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -138,7 +139,7 @@ public class HttpsRouteTest extends BaseJettyTest {
 
         LOG.info("Headers: {}", headers);
 
-        assertTrue(headers.size() > 0, "Should be more than one header but 
was: " + headers);
+        assertFalse(headers.isEmpty(), "Should be more than one header but 
was: " + headers);
     }
 
     @Test
diff --git 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
index 8b0383356f7..10395c8ca15 100644
--- 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
+++ 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
@@ -43,6 +43,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
@@ -116,7 +117,7 @@ public class SpringHttpsRouteTest {
 
         log.info("Headers: {}", headers);
 
-        assertTrue(headers.size() > 0, "Should be more than one header but 
was: " + headers);
+        assertFalse(headers.isEmpty(), "Should be more than one header but 
was: " + headers);
     }
 
     @Test
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/SecurityAuthenticatorSupport.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/SecurityAuthenticatorSupport.java
index e074e8379f1..f8ab24e3b40 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/SecurityAuthenticatorSupport.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/SecurityAuthenticatorSupport.java
@@ -83,13 +83,13 @@ public abstract class SecurityAuthenticatorSupport 
implements SecurityAuthentica
         StringBuilder sb = new StringBuilder();
         for (Principal p : subject.getPrincipals()) {
             if (isRoleClass(p)) {
-                if (sb.length() > 0) {
+                if (!sb.isEmpty()) {
                     sb.append(",");
                 }
                 sb.append(p.getName());
             }
         }
-        if (sb.length() > 0) {
+        if (!sb.isEmpty()) {
             return sb.toString();
         } else {
             return null;
diff --git 
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
 
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
index 0738a279265..90bfbed8478 100644
--- 
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
+++ 
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
@@ -545,7 +545,7 @@ public class MainHttpServer extends ServiceSupport 
implements CamelContextAware,
                             }
                         }
                     });
-                    if (sb.length() > 0) {
+                    if (!sb.isEmpty()) {
                         String out = sb.toString();
                         if (html) {
                             ctx.response().putHeader("content-type", 
"text/html");
@@ -584,7 +584,7 @@ public class MainHttpServer extends ServiceSupport 
implements CamelContextAware,
                             }
                         }
                     });
-                    if (sb.length() > 0) {
+                    if (!sb.isEmpty()) {
                         String out = sb.toString();
                         ctx.end(out);
                     } else if (!root.isEmpty()) {
diff --git 
a/components/camel-platform-http/src/test/java/org/apache/camel/component/platform/http/JettyCustomPlatformHttpConsumer.java
 
b/components/camel-platform-http/src/test/java/org/apache/camel/component/platform/http/JettyCustomPlatformHttpConsumer.java
index f83211f3e78..2305603d0a4 100644
--- 
a/components/camel-platform-http/src/test/java/org/apache/camel/component/platform/http/JettyCustomPlatformHttpConsumer.java
+++ 
b/components/camel-platform-http/src/test/java/org/apache/camel/component/platform/http/JettyCustomPlatformHttpConsumer.java
@@ -123,7 +123,7 @@ public class JettyCustomPlatformHttpConsumer extends 
DefaultConsumer {
             message.setHeader(Exchange.HTTP_CHARACTER_ENCODING, charset);
         }
 
-        message.setBody(body.length() != 0 ? body : null);
+        message.setBody(!body.isEmpty() ? body : null);
         exchange.setMessage(message);
         return exchange;
     }
diff --git 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHelper.java
 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHelper.java
index 432461ecd2e..56b9e578591 100644
--- 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHelper.java
+++ 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHelper.java
@@ -65,7 +65,7 @@ public final class UndertowHelper {
             if (path.startsWith("/")) {
                 path = path.substring(1);
             }
-            if (path.length() > 0) {
+            if (!path.isEmpty()) {
                 // make sure that there is exactly one "/" between HTTP_URI and
                 // HTTP_PATH
                 if (!uri.endsWith("/")) {
diff --git 
a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowHttpPojoTypeTest.java
 
b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowHttpPojoTypeTest.java
index c48cfabeea5..12d688a963f 100644
--- 
a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowHttpPojoTypeTest.java
+++ 
b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowHttpPojoTypeTest.java
@@ -46,7 +46,7 @@ public class RestUndertowHttpPojoTypeTest extends 
BaseUndertowTest {
         List<RestDefinition> restDefinitions
                 = 
context().getCamelContextExtension().getContextPlugin(Model.class).getRestDefinitions();
         assertNotNull(restDefinitions);
-        assertTrue(restDefinitions.size() > 0);
+        assertTrue(!restDefinitions.isEmpty());
 
         RestDefinition restDefinition = restDefinitions.get(0);
         List<VerbDefinition> verbs = restDefinition.getVerbs();
diff --git 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpHelper.java
 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpHelper.java
index 1d003544f36..d6ee8cad4a2 100644
--- 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpHelper.java
+++ 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpHelper.java
@@ -83,7 +83,7 @@ public final class VertxHttpHelper {
             if (path.startsWith("/")) {
                 path = path.substring(1);
             }
-            if (path.length() > 0) {
+            if (!path.isEmpty()) {
                 // make sure that there is exactly one "/" between HTTP_URI and
                 // HTTP_PATH
                 if (!uri.endsWith("/")) {

Reply via email to