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 67463808361607587fea70e16f381132517769ab Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Mon Jan 26 10:44:49 2026 +0000 (chores): modernize instanceof checks in camel-service --- .../org/apache/camel/component/service/ServiceConsumer.java | 12 ++++++------ .../org/apache/camel/component/service/ServiceEndpoint.java | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/camel-service/src/main/java/org/apache/camel/component/service/ServiceConsumer.java b/components/camel-service/src/main/java/org/apache/camel/component/service/ServiceConsumer.java index ada95b7a513c..41daa38fd936 100644 --- a/components/camel-service/src/main/java/org/apache/camel/component/service/ServiceConsumer.java +++ b/components/camel-service/src/main/java/org/apache/camel/component/service/ServiceConsumer.java @@ -65,8 +65,8 @@ public class ServiceConsumer extends DefaultConsumer { // start delegate delegatedConsumer = delegatedEndpoint.createConsumer(processor); - if (delegatedConsumer instanceof StartupListener) { - getEndpoint().getCamelContext().addStartupListener((StartupListener) delegatedConsumer); + if (delegatedConsumer instanceof StartupListener startuplistener) { + getEndpoint().getCamelContext().addStartupListener(startuplistener); } ServiceHelper.startService(delegatedEndpoint); @@ -92,28 +92,28 @@ public class ServiceConsumer extends DefaultConsumer { @Override protected void doResume() throws Exception { - if (delegatedConsumer instanceof SuspendableService) { + if (delegatedConsumer instanceof SuspendableService suspendableService) { final ServiceEndpoint endpoint = (ServiceEndpoint) getEndpoint(); final ServiceDefinition definition = endpoint.getServiceDefinition(); // register service serviceRegistry.register(definition); - ((SuspendableService) delegatedConsumer).resume(); + suspendableService.resume(); } super.doResume(); } @Override protected void doSuspend() throws Exception { - if (delegatedConsumer instanceof SuspendableService) { + if (delegatedConsumer instanceof SuspendableService suspendableservice) { final ServiceEndpoint endpoint = (ServiceEndpoint) getEndpoint(); final ServiceDefinition definition = endpoint.getServiceDefinition(); // de-register service serviceRegistry.deregister(definition); - ((SuspendableService) delegatedConsumer).suspend(); + suspendableservice.suspend(); } super.doSuspend(); } diff --git a/components/camel-service/src/main/java/org/apache/camel/component/service/ServiceEndpoint.java b/components/camel-service/src/main/java/org/apache/camel/component/service/ServiceEndpoint.java index 4c57ac61c5de..bb23ea52ec05 100644 --- a/components/camel-service/src/main/java/org/apache/camel/component/service/ServiceEndpoint.java +++ b/components/camel-service/src/main/java/org/apache/camel/component/service/ServiceEndpoint.java @@ -106,8 +106,8 @@ public class ServiceEndpoint extends DefaultEndpoint implements DelegateEndpoint private ServiceDefinition computeServiceDefinition(CamelContext context, Endpoint delegateEndpoint) { Map<String, String> parameters = new HashMap<>(); - if (delegateEndpoint instanceof DiscoverableService) { - parameters.putAll(((DiscoverableService) delegateEndpoint).getServiceProperties()); + if (delegateEndpoint instanceof DiscoverableService discoverableservice) { + parameters.putAll(discoverableservice.getServiceProperties()); } parameters.putAll(serviceParameters);
