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 a093e59c91ad954b44772f9dd3a20bb7f1048cdd
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Mon Aug 26 11:50:00 2024 +0200

    (chores) camel-disruptor simplify type checks
    
    - to use pattern matching for instanceof
    - use simpler assertion checks
---
 .../org/apache/camel/component/disruptor/DisruptorReference.java    | 6 ++----
 .../component/disruptor/DisruptorWaitStrategyCreationTest.java      | 4 ++--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git 
a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorReference.java
 
b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorReference.java
index 3922fe8a3e0..ce09adfe3b5 100644
--- 
a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorReference.java
+++ 
b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorReference.java
@@ -259,10 +259,9 @@ public class DisruptorReference {
             //we need to shut down our executor
             
component.getCamelContext().getExecutorServiceManager().shutdown(executor);
             executor = null;
-        } else if (executor instanceof ThreadPoolExecutor) {
+        } else if (executor instanceof ThreadPoolExecutor threadPoolExecutor) {
             LOGGER.debug("Resizing existing executor to {} threads", newSize);
             //our thread pool executor is of type ThreadPoolExecutor, we know 
how to resize it
-            final ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) 
executor;
             //Java 9 support, checkout 
http://download.java.net/java/jdk9/docs/api/java/util/concurrent/ThreadPoolExecutor.html#setCorePoolSize-int-
             // and 
http://download.java.net/java/jdk9/docs/api/java/util/concurrent/ThreadPoolExecutor.html#setMaximumPoolSize-int-
             //for more information
@@ -291,10 +290,9 @@ public class DisruptorReference {
         if (currentDisruptor != null) {
             //check if we had a blocking event handler to keep an empty 
disruptor 'busy'
             if (handlers != null && handlers.length == 1
-                    && handlers[0] instanceof BlockingExchangeEventHandler) {
+                    && handlers[0] instanceof BlockingExchangeEventHandler 
blockingExchangeEventHandler) {
                 // yes we did, unblock it so we can get rid of our backlog,
                 // The eventhandler will empty its pending exchanges in our 
temporary buffer
-                final BlockingExchangeEventHandler 
blockingExchangeEventHandler = (BlockingExchangeEventHandler) handlers[0];
                 blockingExchangeEventHandler.unblock();
             }
 
diff --git 
a/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorWaitStrategyCreationTest.java
 
b/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorWaitStrategyCreationTest.java
index 251d31213ed..94bd8dbbf34 100644
--- 
a/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorWaitStrategyCreationTest.java
+++ 
b/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorWaitStrategyCreationTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.disruptor;
 import com.lmax.disruptor.WaitStrategy;
 import org.junit.jupiter.api.Test;
 
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Tests correct creation of all supposedly possible wait strategies.
@@ -32,7 +32,7 @@ public class DisruptorWaitStrategyCreationTest {
             final WaitStrategy waitStrategyInstance = 
strategy.createWaitStrategyInstance();
 
             assertNotNull(waitStrategyInstance);
-            assertTrue(waitStrategyInstance instanceof WaitStrategy);
+            assertInstanceOf(WaitStrategy.class, waitStrategyInstance);
         }
     }
 }

Reply via email to