You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2026/01/26 13:01:38 UTC
(camel) branch main updated (5e1e79a7c6e7 -> 830c91b7b12b)
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
from 5e1e79a7c6e7 Include Spring Boot configuration partial in openai-component.adoc
new 27afdf8e6012 (chores): modernize instanceof checks in camel-mock
new 0dec67585276 (chores): modernize instanceof checks in camel-route-parser
new 25ba10adf4df (chores): modernize instanceof checks in camel-bean
new a1820b681716 (chores): modernize instanceof checks in camel-beanio
new 613d12b1e379 (chores): modernize instanceof checks in camel-kafka
new aacf00397d42 (chores): modernize instanceof checks in camel-slack
new b44c927e06c1 (chores): modernize instanceof checks in camel-jslt
new 82e343f4fda3 (chores): modernize instanceof checks in camel-jdbc
new 1f31ef5c286c (chores): modernize instanceof checks in camel-stitch
new 0335db1c3799 (chores): modernize instanceof checks in camel-smooks
new 674638083616 (chores): modernize instanceof checks in camel-service
new add8bb278981 (chores): modernize instanceof checks in camel-kubernetes
new c738926521a5 (chores): modernize instanceof checks in camel-console
new 7fc42d6e99bd (chores): modernize instanceof checks in camel-core-model
new d381c6f0fb31 (chores): modernize instanceof checks in camel-util
new cd0e6dd80893 (chores): modernize instanceof checks in camel-quartz
new f4523fa413bd (chores): modernize instanceof checks in camel-webhook
new b0588f310e93 (chores): modernize instanceof checks in camel-platform-http-vertx
new e64a71e95c87 (chores): modernize instanceof checks in camel-activemq
new e74898f2e345 (chores): modernize instanceof checks in camel-activemq6
new 447b0d13a309 (chores): modernize instanceof checks in camel-jira
new 3b2c2a971c63 (chores): modernize instanceof checks in camel-amqp
new 05d4dcf801c6 (chores): modernize instanceof checks in camel-bindy
new e99558bbdc20 (chores): modernize instanceof checks in camel-file
new 4f4476239a8d (chores): modernize instanceof checks in camel-jms
new 3f77303a47fc (chores): modernize instanceof checks in camel-cron
new 9ed34a3c762b (chores): modernize instanceof checks in camel-csv
new d9d2cb2500f9 (chores): modernize instanceof checks in camel-exec
new 091bce55cad5 (chores): modernize instanceof checks in camel-hazelcast
new d0ce524136d3 (chores): modernize instanceof checks in camel-mongodb
new 067d1c1c272a (chores): modernize instanceof checks in camel-nats
new c7535cddbeac (chores): modernize instanceof checks in camel-jpa
new de9dd13559c6 (chores): modernize instanceof checks in camel-jq
new 5239836a877b (chores): modernize instanceof checks in camel-mustache
new 4a144bd04311 (chores): modernize instanceof checks in camel-printer
new 3181a8424f41 (chores): modernize instanceof checks in camel-zipfile
new 061d5ce6290b (chores): modernize instanceof checks in camel-attachments
new 0346116a5a47 (chores): modernize instanceof checks in camel-xslt
new 7e139e4709f6 (chores): modernize instanceof checks in camel-stax
new 064862567e31 (chores): modernize instanceof checks in camel-stream
new 830c91b7b12b (chores): modernize instanceof checks in camel-zookeeper
The 41 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../camel/parser/helper/CamelJavaParserHelper.java | 20 +++++------
.../helper/CamelJavaRestDslParserHelper.java | 40 +++++++++++-----------
.../parser/helper/CamelJavaTreeParserHelper.java | 40 +++++++++++-----------
.../apache/camel/parser/helper/CamelXmlHelper.java | 4 +--
.../apache/camel/parser/helper/ParserCommon.java | 8 ++---
.../component/activemq/ActiveMQComponent.java | 4 +--
.../component/activemq/ActiveMQConfiguration.java | 4 +--
.../OriginalDestinationPropagateStrategy.java | 4 +--
.../converter/ActiveMQMessageConverter.java | 8 ++---
.../component/activemq6/ActiveMQComponent.java | 4 +--
.../component/activemq6/ActiveMQConfiguration.java | 4 +--
.../OriginalDestinationPropagateStrategy.java | 4 +--
.../converter/ActiveMQMessageConverter.java | 8 ++---
.../camel/component/amqp/AMQPJmsBinding.java | 4 +--
.../apache/camel/attachment/DefaultAttachment.java | 12 +++----
.../bean/AbstractCamelInvocationHandler.java | 8 ++---
.../apache/camel/component/bean/MethodInfo.java | 20 +++++------
.../apache/camel/language/bean/BeanLanguage.java | 4 +--
.../camel/dataformat/beanio/BeanIODataFormat.java | 4 +--
.../camel/dataformat/beanio/BeanIOHelper.java | 3 +-
.../camel/dataformat/beanio/BeanIOSplitter.java | 7 ++--
.../bindy/format/NumberPatternFormat.java | 3 +-
.../apache/camel/component/cron/CronComponent.java | 3 +-
.../apache/camel/dataformat/csv/CsvMarshaller.java | 3 +-
.../exec/impl/DefaultExecCommandExecutor.java | 4 +--
.../camel/component/file/GenericFileProducer.java | 2 +-
.../hazelcast/seda/HazelcastSedaConsumer.java | 4 +--
.../apache/camel/component/jdbc/JdbcProducer.java | 16 ++++-----
.../camel/component/jdbc/ResultSetIterator.java | 4 +--
.../jira/producer/AttachFileProducer.java | 4 +--
.../camel/component/jms/JmsConfiguration.java | 3 +-
.../apache/camel/component/jpa/JpaProducer.java | 4 +--
.../org/apache/camel/language/jq/JqExpression.java | 4 +--
.../apache/camel/component/jslt/JsltEndpoint.java | 20 +++++------
.../component/kafka/KafkaHeaderDeserializer.java | 4 +--
.../component/kafka/transform/TimestampRouter.java | 8 ++---
.../config_maps/vault/ConfigmapsDevConsole.java | 4 +--
.../vault/ConfigmapsReloadTriggerTask.java | 4 +--
.../secrets/vault/SecretsDevConsole.java | 4 +--
.../secrets/vault/SecretsReloadTriggerTask.java | 4 +--
.../camel/component/mock/MockValueBuilder.java | 19 +++++-----
.../camel/component/mongodb/MongoDbComponent.java | 4 +--
.../camel/component/mustache/MustacheEndpoint.java | 4 +--
.../apache/camel/component/nats/NatsProducer.java | 4 +--
.../http/vertx/VertxPlatformHttpSupport.java | 20 +++++------
.../camel/component/printer/PrinterProducer.java | 3 +-
.../apache/camel/component/quartz/CamelJob.java | 11 +++---
.../camel/component/quartz/QuartzEndpoint.java | 11 ++----
.../quartz/QuartzScheduledPollConsumerJob.java | 4 +--
.../QuartzScheduledPollConsumerScheduler.java | 8 ++---
.../camel/routepolicy/quartz/ScheduledJob.java | 4 +--
.../camel/component/service/ServiceConsumer.java | 12 +++----
.../camel/component/service/ServiceEndpoint.java | 4 +--
.../camel/component/slack/SlackProducer.java | 16 ++++-----
.../camel/component/smooks/SmooksProcessor.java | 16 ++++-----
.../apache/camel/component/stax/StAXProcessor.java | 4 +--
.../language/xtokenizer/XMLTokenizeLanguage.java | 4 +--
.../operations/StitchProducerOperations.java | 16 ++++-----
.../camel/component/stream/StreamConsumer.java | 8 ++---
.../component/webhook/WebhookRoutePolicy.java | 3 +-
.../camel/component/webhook/WebhookUtils.java | 16 ++++-----
.../xslt/XmlSourceHandlerFactoryImpl.java | 4 +--
.../apache/camel/component/xslt/XsltBuilder.java | 4 +--
.../camel/dataformat/zipfile/ZipIterator.java | 4 +--
.../camel/component/zookeeper/ZooKeeperUtils.java | 4 +--
.../zookeeper/operations/OperationResult.java | 4 +--
.../camel/impl/console/PropertiesDevConsole.java | 8 ++---
.../apache/camel/model/ExpressionNodeHelper.java | 6 ++--
.../apache/camel/model/OnCompletionDefinition.java | 4 +--
.../apache/camel/model/ResequenceDefinition.java | 10 +++---
.../java/org/apache/camel/util/ObjectHelper.java | 4 +--
.../util/concurrent/RejectableFutureTask.java | 4 +--
72 files changed, 272 insertions(+), 291 deletions(-)
(camel) 09/41: (chores): modernize instanceof checks in camel-stitch
Posted by or...@apache.org.
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 1f31ef5c286c42aae48efe5e6574c005faa0ac01
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:43:12 2026 +0000
(chores): modernize instanceof checks in camel-stitch
---
.../stitch/operations/StitchProducerOperations.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/components/camel-stitch/src/main/java/org/apache/camel/component/stitch/operations/StitchProducerOperations.java b/components/camel-stitch/src/main/java/org/apache/camel/component/stitch/operations/StitchProducerOperations.java
index 1c2ab633740a..5c35457d7e68 100644
--- a/components/camel-stitch/src/main/java/org/apache/camel/component/stitch/operations/StitchProducerOperations.java
+++ b/components/camel-stitch/src/main/java/org/apache/camel/component/stitch/operations/StitchProducerOperations.java
@@ -118,19 +118,19 @@ public class StitchProducerOperations {
final Collection<StitchMessage> stitchMessages = new LinkedList<>();
inputData.forEach(data -> {
- if (data instanceof StitchMessage) {
- stitchMessages.add((StitchMessage) data);
+ if (data instanceof StitchMessage stitchmessage) {
+ stitchMessages.add(stitchmessage);
} else if (data instanceof Map) {
stitchMessages.add(StitchMessage.fromMap(ObjectHelper.cast(Map.class, data)).build());
- } else if (data instanceof StitchRequestBody) {
- stitchMessages.addAll(((StitchRequestBody) data).getMessages());
- } else if (data instanceof Message) {
- final Message camelNestedMessage = (Message) data;
+ } else if (data instanceof StitchRequestBody stitchrequestbody) {
+ stitchMessages.addAll(stitchrequestbody.getMessages());
+ } else if (data instanceof Message camelNestedMessage2) {
+ final Message camelNestedMessage = camelNestedMessage2;
// set all the headers from parent message
camelNestedMessage.setHeaders(message.getHeaders());
stitchMessages.addAll(createStitchRequestBody(camelNestedMessage).getMessages());
- } else if (data instanceof Exchange) {
- final Message camelNestedMessage = ((Exchange) data).getMessage();
+ } else if (data instanceof Exchange exchange) {
+ final Message camelNestedMessage = (exchange).getMessage();
// set all the headers from parent message
camelNestedMessage.setHeaders(message.getHeaders());
stitchMessages.addAll(createStitchRequestBody(camelNestedMessage).getMessages());
(camel) 27/41: (chores): modernize instanceof checks in camel-csv
Posted by or...@apache.org.
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 9ed34a3c762b1bfcfbbf4a7d7d5a3beaea4b0d55
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:26:15 2026 +0000
(chores): modernize instanceof checks in camel-csv
---
.../src/main/java/org/apache/camel/dataformat/csv/CsvMarshaller.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvMarshaller.java b/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvMarshaller.java
index a67bbf68747a..6cef2740940e 100644
--- a/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvMarshaller.java
+++ b/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvMarshaller.java
@@ -80,8 +80,7 @@ public abstract class CsvMarshaller {
throws NoTypeConversionAvailableException, IOException {
CSVPrinter printer = createPrinter(exchange, outputStream);
try {
- if (object instanceof Map) {
- Map map = (Map) object;
+ if (object instanceof Map map) {
printer.printRecord(getMapRecordValues(map));
} else {
Iterator it = ObjectHelper.createIterator(object);
(camel) 21/41: (chores): modernize instanceof checks in camel-jira
Posted by or...@apache.org.
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 447b0d13a3096a772bb58ec7cd66da97919e95b8
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:14:42 2026 +0000
(chores): modernize instanceof checks in camel-jira
---
.../org/apache/camel/component/jira/producer/AttachFileProducer.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/AttachFileProducer.java b/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/AttachFileProducer.java
index e04bda02d5e2..0f59c35ee603 100644
--- a/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/AttachFileProducer.java
+++ b/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/AttachFileProducer.java
@@ -49,8 +49,8 @@ public class AttachFileProducer extends DefaultProducer {
String name = null;
File file = null;
Object body = exchange.getIn().getBody();
- if (body instanceof File) {
- file = (File) body;
+ if (body instanceof File fileBody) {
+ file = fileBody;
} else {
WrappedFile<?> wf = exchange.getIn().getBody(WrappedFile.class);
if (wf != null && wf.getFile() instanceof File) {
(camel) 19/41: (chores): modernize instanceof checks in camel-activemq
Posted by or...@apache.org.
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 e64a71e95c87f8339ad80f3e6c70b34cff540822
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:11:44 2026 +0000
(chores): modernize instanceof checks in camel-activemq
---
.../org/apache/camel/component/activemq/ActiveMQComponent.java | 4 ++--
.../apache/camel/component/activemq/ActiveMQConfiguration.java | 4 ++--
.../component/activemq/OriginalDestinationPropagateStrategy.java | 4 ++--
.../component/activemq/converter/ActiveMQMessageConverter.java | 8 ++++----
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java
index d2df48853d24..119ca00a306d 100644
--- a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java
+++ b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java
@@ -78,8 +78,8 @@ public class ActiveMQComponent extends JmsComponent {
*/
public static ActiveMQComponent activeMQComponent(String brokerURL) {
ActiveMQComponent answer = new ActiveMQComponent();
- if (answer.getConfiguration() instanceof ActiveMQConfiguration) {
- ((ActiveMQConfiguration) answer.getConfiguration()).setBrokerURL(brokerURL);
+ if (answer.getConfiguration() instanceof ActiveMQConfiguration activeMQConfiguration) {
+ activeMQConfiguration.setBrokerURL(brokerURL);
}
return answer;
diff --git a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQConfiguration.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQConfiguration.java
index 0f32d9d36e85..cf10c7f8e48c 100644
--- a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQConfiguration.java
+++ b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQConfiguration.java
@@ -148,8 +148,8 @@ public class ActiveMQConfiguration extends JmsConfiguration {
if (target instanceof DelegatingConnectionFactory dcf) {
target = dcf.getTargetConnectionFactory();
}
- if (target instanceof ActiveMQConnectionFactory) {
- acf = (ActiveMQConnectionFactory) target;
+ if (target instanceof ActiveMQConnectionFactory activeMQConnectionFactory) {
+ acf = activeMQConnectionFactory;
}
if (acf != null) {
diff --git a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/OriginalDestinationPropagateStrategy.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/OriginalDestinationPropagateStrategy.java
index 51d3b450a4b0..7a0d66766e5d 100644
--- a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/OriginalDestinationPropagateStrategy.java
+++ b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/OriginalDestinationPropagateStrategy.java
@@ -40,12 +40,12 @@ public class OriginalDestinationPropagateStrategy implements MessageCreatedStrat
if (exchange.getIn() instanceof JmsMessage) {
JmsMessage msg = exchange.getIn(JmsMessage.class);
Message jms = msg.getJmsMessage();
- if (jms instanceof ActiveMQMessage amq && message instanceof ActiveMQMessage) {
+ if (jms instanceof ActiveMQMessage amq && message instanceof ActiveMQMessage activeMQMessage) {
if (amq.getOriginalDestination() == null) {
ActiveMQDestination from = amq.getDestination();
if (from != null) {
LOG.trace("Setting OriginalDestination: {} on {}", from, message);
- ((ActiveMQMessage) message).setOriginalDestination(from);
+ activeMQMessage.setOriginalDestination(from);
}
}
}
diff --git a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/converter/ActiveMQMessageConverter.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/converter/ActiveMQMessageConverter.java
index 935258edd982..629b256054dd 100644
--- a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/converter/ActiveMQMessageConverter.java
+++ b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/converter/ActiveMQMessageConverter.java
@@ -71,13 +71,13 @@ public class ActiveMQMessageConverter {
private static ActiveMQMessage createActiveMQMessage(Exchange exchange) throws JMSException {
Object body = exchange.getIn().getBody();
- if (body instanceof String) {
+ if (body instanceof String str) {
ActiveMQTextMessage answer = new ActiveMQTextMessage();
- answer.setText((String) body);
+ answer.setText(str);
return answer;
- } else if (body instanceof Serializable) {
+ } else if (body instanceof Serializable serializable) {
ActiveMQObjectMessage answer = new ActiveMQObjectMessage();
- answer.setObject((Serializable) body);
+ answer.setObject(serializable);
return answer;
} else {
return new ActiveMQMessage();
(camel) 10/41: (chores): modernize instanceof checks in camel-smooks
Posted by or...@apache.org.
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 0335db1c379970691c8a645399ad1f3f8f216c4f
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:44:08 2026 +0000
(chores): modernize instanceof checks in camel-smooks
---
.../apache/camel/component/smooks/SmooksProcessor.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java
index 3e61290b4976..832a448cc7ff 100644
--- a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java
+++ b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksProcessor.java
@@ -184,24 +184,24 @@ public class SmooksProcessor extends ServiceSupport implements Processor, CamelC
private Source getSource(final Exchange exchange) throws InvalidPayloadException {
final Object payload = exchange.getIn().getBody();
- if (payload instanceof Source) {
- return (Source) payload;
+ if (payload instanceof Source source) {
+ return source;
}
- if (payload instanceof byte[]) {
- return new ByteSource((byte[]) payload);
+ if (payload instanceof byte[] byteArray) {
+ return new ByteSource(byteArray);
}
if (payload instanceof Node) {
return new DOMSource((Node) payload);
}
- if (payload instanceof InputStream) {
- return new StreamSource<>((InputStream) payload);
+ if (payload instanceof InputStream inputstream) {
+ return new StreamSource<>(inputstream);
}
- if (payload instanceof Reader) {
- return new ReaderSource<>((Reader) payload);
+ if (payload instanceof Reader reader) {
+ return new ReaderSource<>(reader);
}
if (payload instanceof WrappedFile) {
(camel) 07/41: (chores): modernize instanceof checks in camel-jslt
Posted by or...@apache.org.
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 b44c927e06c1a0838c8236a576ba7f3998f1854d
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:41:30 2026 +0000
(chores): modernize instanceof checks in camel-jslt
---
.../apache/camel/component/jslt/JsltEndpoint.java | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/components/camel-jslt/src/main/java/org/apache/camel/component/jslt/JsltEndpoint.java b/components/camel-jslt/src/main/java/org/apache/camel/component/jslt/JsltEndpoint.java
index 5476715789a7..3ca8c381dcc5 100644
--- a/components/camel-jslt/src/main/java/org/apache/camel/component/jslt/JsltEndpoint.java
+++ b/components/camel-jslt/src/main/java/org/apache/camel/component/jslt/JsltEndpoint.java
@@ -218,16 +218,16 @@ public class JsltEndpoint extends ResourceEndpoint {
if (body instanceof WrappedFile) {
body = ((WrappedFile<?>) body).getFile();
}
- if (body instanceof String) {
- input = objectMapper.readTree((String) body);
- } else if (body instanceof Reader) {
- input = objectMapper.readTree((Reader) body);
- } else if (body instanceof File) {
- input = objectMapper.readTree((File) body);
- } else if (body instanceof byte[]) {
- input = objectMapper.readTree((byte[]) body);
- } else if (body instanceof InputStream) {
- input = objectMapper.readTree((InputStream) body);
+ if (body instanceof String string) {
+ input = objectMapper.readTree(string);
+ } else if (body instanceof Reader reader) {
+ input = objectMapper.readTree(reader);
+ } else if (body instanceof File file) {
+ input = objectMapper.readTree(file);
+ } else if (body instanceof byte[] byteArray) {
+ input = objectMapper.readTree(byteArray);
+ } else if (body instanceof InputStream inputstream) {
+ input = objectMapper.readTree(inputstream);
} else {
throw new ValidationException(exchange, "Allowed body types are String, Reader, File, byte[] or InputStream.");
}
(camel) 25/41: (chores): modernize instanceof checks in camel-jms
Posted by or...@apache.org.
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 4f4476239a8d92295b506802f3ffdf8fe794fa05
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:24:10 2026 +0000
(chores): modernize instanceof checks in camel-jms
---
.../src/main/java/org/apache/camel/component/jms/JmsConfiguration.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
index ca7728903c2f..94d59ddd0a90 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
@@ -719,8 +719,7 @@ public class JmsConfiguration implements Cloneable {
public JmsOperations createInOutTemplate(
JmsEndpoint endpoint, boolean pubSubDomain, String destination, long requestTimeout) {
JmsOperations answer = createInOnlyTemplate(endpoint, pubSubDomain, destination);
- if (answer instanceof JmsTemplate && requestTimeout > 0) {
- JmsTemplate jmsTemplate = (JmsTemplate) answer;
+ if (answer instanceof JmsTemplate jmsTemplate && requestTimeout > 0) {
jmsTemplate.setExplicitQosEnabled(true);
// prefer to use timeToLive over requestTimeout if both specified
(camel) 08/41: (chores): modernize instanceof checks in camel-jdbc
Posted by or...@apache.org.
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 82e343f4fda32a5746dfbc422c3c1d8e67f6780b
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:42:19 2026 +0000
(chores): modernize instanceof checks in camel-jdbc
---
.../org/apache/camel/component/jdbc/JdbcProducer.java | 16 ++++++++--------
.../apache/camel/component/jdbc/ResultSetIterator.java | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
index d2cf535c525b..f56bb7588cfe 100644
--- a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
+++ b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
@@ -173,10 +173,10 @@ public class JdbcProducer extends DefaultProducer {
Object expectedGeneratedColumns = exchange.getIn().getHeader(JdbcConstants.JDBC_GENERATED_COLUMNS);
if (expectedGeneratedColumns == null) {
ps = conn.prepareStatement(preparedQuery, Statement.RETURN_GENERATED_KEYS);
- } else if (expectedGeneratedColumns instanceof String[]) {
- ps = conn.prepareStatement(preparedQuery, (String[]) expectedGeneratedColumns);
- } else if (expectedGeneratedColumns instanceof int[]) {
- ps = conn.prepareStatement(preparedQuery, (int[]) expectedGeneratedColumns);
+ } else if (expectedGeneratedColumns instanceof String[] stringArray) {
+ ps = conn.prepareStatement(preparedQuery, stringArray);
+ } else if (expectedGeneratedColumns instanceof int[] intArray) {
+ ps = conn.prepareStatement(preparedQuery, intArray);
} else {
throw new IllegalArgumentException(
"Header specifying expected returning columns isn't an instance of String[] or int[] but "
@@ -256,10 +256,10 @@ public class JdbcProducer extends DefaultProducer {
Object expectedGeneratedColumns = exchange.getIn().getHeader(JdbcConstants.JDBC_GENERATED_COLUMNS);
if (expectedGeneratedColumns == null) {
stmtExecutionResult = stmt.execute(sql, Statement.RETURN_GENERATED_KEYS);
- } else if (expectedGeneratedColumns instanceof String[]) {
- stmtExecutionResult = stmt.execute(sql, (String[]) expectedGeneratedColumns);
- } else if (expectedGeneratedColumns instanceof int[]) {
- stmtExecutionResult = stmt.execute(sql, (int[]) expectedGeneratedColumns);
+ } else if (expectedGeneratedColumns instanceof String[] stringArray) {
+ stmtExecutionResult = stmt.execute(sql, stringArray);
+ } else if (expectedGeneratedColumns instanceof int[] intArray) {
+ stmtExecutionResult = stmt.execute(sql, intArray);
} else {
throw new IllegalArgumentException(
"Header specifying expected returning columns isn't an instance of String[] or int[] but "
diff --git a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/ResultSetIterator.java b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/ResultSetIterator.java
index a44abb7a3475..99c1dab505a3 100644
--- a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/ResultSetIterator.java
+++ b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/ResultSetIterator.java
@@ -83,8 +83,8 @@ public class ResultSetIterator implements Iterator<Map<String, Object>> {
try {
Map<String, Object> row = new LinkedHashMap<>();
for (Column column : columns) {
- if (useGetBytes && column instanceof BlobColumn) {
- row.put(column.getName(), ((BlobColumn) column).getBytes(resultSet));
+ if (useGetBytes && column instanceof BlobColumn blobcolumn) {
+ row.put(column.getName(), blobcolumn.getBytes(resultSet));
} else {
row.put(column.getName(), column.getValue(resultSet));
}
(camel) 41/41: (chores): modernize instanceof checks in camel-zookeeper
Posted by or...@apache.org.
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 830c91b7b12b0ff332297b13f94eabf8ac455628
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 12:00:35 2026 +0000
(chores): modernize instanceof checks in camel-zookeeper
---
.../java/org/apache/camel/component/zookeeper/ZooKeeperUtils.java | 4 ++--
.../apache/camel/component/zookeeper/operations/OperationResult.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperUtils.java b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperUtils.java
index 04f5362e7659..a51b7795a48b 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperUtils.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperUtils.java
@@ -105,8 +105,8 @@ public final class ZooKeeperUtils {
public static WatchedEvent getWatchedEvent(ZooKeeperOperation<?> zooKeeperOperation) {
WatchedEvent watchedEvent = null;
- if (zooKeeperOperation instanceof WatchedEventProvider) {
- watchedEvent = ((WatchedEventProvider) zooKeeperOperation).getWatchedEvent();
+ if (zooKeeperOperation instanceof WatchedEventProvider watchedEventProvider) {
+ watchedEvent = watchedEventProvider.getWatchedEvent();
}
return watchedEvent;
}
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/operations/OperationResult.java b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/operations/OperationResult.java
index ebfb5226a802..3b171e364cff 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/operations/OperationResult.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/operations/OperationResult.java
@@ -61,10 +61,10 @@ public class OperationResult<ResultType> {
}
public boolean failedDueTo(Code... codes) {
- if (exception instanceof KeeperException) {
+ if (exception instanceof KeeperException keeperException) {
for (Code code : codes) {
- if (code.equals(((KeeperException) exception).code())) {
+ if (code.equals(keeperException.code())) {
return true;
}
}
(camel) 39/41: (chores): modernize instanceof checks in camel-stax
Posted by or...@apache.org.
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 7e139e4709f67b17d35e3dd389fff1c728460c88
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:53:27 2026 +0000
(chores): modernize instanceof checks in camel-stax
---
.../src/main/java/org/apache/camel/component/stax/StAXProcessor.java | 4 ++--
.../org/apache/camel/language/xtokenizer/XMLTokenizeLanguage.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXProcessor.java b/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXProcessor.java
index 38fbb1f5ff65..2fb8e0961a44 100644
--- a/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXProcessor.java
+++ b/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXProcessor.java
@@ -71,9 +71,9 @@ public class StAXProcessor implements Processor {
} finally {
if (stream != null) {
stream.close();
- if (stream instanceof ValidatingStreamReader) {
+ if (stream instanceof ValidatingStreamReader validatingStreamReader) {
// didn't find any method without using the woodstox package
- ((ValidatingStreamReader) stream).closeCompletely();
+ validatingStreamReader.closeCompletely();
}
}
}
diff --git a/components/camel-stax/src/main/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguage.java b/components/camel-stax/src/main/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguage.java
index 2826207c362a..7a4128191096 100644
--- a/components/camel-stax/src/main/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguage.java
+++ b/components/camel-stax/src/main/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguage.java
@@ -58,8 +58,8 @@ public class XMLTokenizeLanguage extends SingleInputTypedLanguageSupport {
Object obj = properties[4];
if (obj != null) {
Namespaces ns;
- if (obj instanceof Namespaces) {
- ns = (Namespaces) obj;
+ if (obj instanceof Namespaces namespaces) {
+ ns = namespaces;
} else if (obj instanceof Map) {
ns = new Namespaces();
((Map<String, String>) obj).forEach(ns::add);
(camel) 40/41: (chores): modernize instanceof checks in camel-stream
Posted by or...@apache.org.
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 064862567e31874cab7bb0f3fbba6ee153cddaa1
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:54:52 2026 +0000
(chores): modernize instanceof checks in camel-stream
---
.../java/org/apache/camel/component/stream/StreamConsumer.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java b/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
index dc8bc7a7d569..feee7a452c5a 100644
--- a/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
+++ b/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
@@ -476,8 +476,8 @@ public class StreamConsumer extends DefaultConsumer implements Runnable {
} catch (IOException e) {
// close the http connection to avoid
// leaking gaps in case of an exception
- if (urlConnectionToClose instanceof HttpURLConnection) {
- ((HttpURLConnection) urlConnectionToClose).disconnect();
+ if (urlConnectionToClose instanceof HttpURLConnection httpURLConnection) {
+ httpURLConnection.disconnect();
}
throw e;
}
@@ -515,9 +515,9 @@ public class StreamConsumer extends DefaultConsumer implements Runnable {
}
private static void closeURLConnection(URLConnection con) {
- if (con instanceof HttpURLConnection) {
+ if (con instanceof HttpURLConnection httpURLConnection) {
try {
- ((HttpURLConnection) con).disconnect();
+ httpURLConnection.disconnect();
} catch (Exception e) {
// ignore
}
(camel) 24/41: (chores): modernize instanceof checks in camel-file
Posted by or...@apache.org.
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 e99558bbdc20970d4c4a46b6a77e02fc50e02f85
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:17:43 2026 +0000
(chores): modernize instanceof checks in camel-file
---
.../main/java/org/apache/camel/component/file/GenericFileProducer.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
index 22f3eff0c42c..6b530fe654c0 100644
--- a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
+++ b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
@@ -374,7 +374,7 @@ public class GenericFileProducer<T> extends DefaultAsyncProducer {
exchange.getIn().setHeader(FileConstants.FILE_NAME, value);
}
- if (value instanceof String && StringHelper.hasStartToken((String) value, "simple")) {
+ if (value instanceof String str && StringHelper.hasStartToken(str, "simple")) {
LOG.warn(
"Simple expression: {} detected in header: {} of type String. This feature has been removed (see CAMEL-6748).",
value, FileConstants.FILE_NAME);
(camel) 14/41: (chores): modernize instanceof checks in camel-core-model
Posted by or...@apache.org.
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 7fc42d6e99bddb325aca0796c7c3e4fa87ffe46a
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:49:45 2026 +0000
(chores): modernize instanceof checks in camel-core-model
---
.../main/java/org/apache/camel/model/ExpressionNodeHelper.java | 6 ++----
.../java/org/apache/camel/model/OnCompletionDefinition.java | 4 ++--
.../main/java/org/apache/camel/model/ResequenceDefinition.java | 10 ++++++----
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/ExpressionNodeHelper.java b/core/camel-core-model/src/main/java/org/apache/camel/model/ExpressionNodeHelper.java
index 9c1051394f15..3a0f85781e19 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/ExpressionNodeHelper.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/ExpressionNodeHelper.java
@@ -43,9 +43,8 @@ public final class ExpressionNodeHelper {
*/
public static ExpressionDefinition toExpressionDefinition(Expression expression) {
// NOTE: XPathBuilder class is not available at compilation time.
- if (expression instanceof ExpressionResultTypeAware
+ if (expression instanceof ExpressionResultTypeAware aware
&& expression.getClass().getName().equals("org.apache.camel.language.xpath.XPathBuilder")) { // NOSONAR
- ExpressionResultTypeAware aware = (ExpressionResultTypeAware) expression;
// we keep the original expression by using the constructor that
// accepts an expression
XPathExpression answer = new XPathExpression(expression);
@@ -74,9 +73,8 @@ public final class ExpressionNodeHelper {
*/
public static ExpressionDefinition toExpressionDefinition(Predicate predicate) {
// NOTE: XPathBuilder class is not available at compilation time.
- if (predicate instanceof ExpressionResultTypeAware
+ if (predicate instanceof ExpressionResultTypeAware aware
&& predicate.getClass().getName().equals("org.apache.camel.language.xpath.XPathBuilder")) { // NOSONAR
- ExpressionResultTypeAware aware = (ExpressionResultTypeAware) predicate;
Expression expression = (Expression) predicate;
// we keep the original expression by using the constructor that
// accepts an expression
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/OnCompletionDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/OnCompletionDefinition.java
index 2a30286bfca6..bec792c32a2a 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/OnCompletionDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/OnCompletionDefinition.java
@@ -141,8 +141,8 @@ public class OnCompletionDefinition extends OutputDefinition<OnCompletionDefinit
* @param definition the parent definition that is the route
*/
public void removeAllOnCompletionDefinition(ProcessorDefinition<?> definition) {
- definition.getOutputs().removeIf(out -> out instanceof OnCompletionDefinition &&
- !((OnCompletionDefinition) out).isRouteScoped());
+ definition.getOutputs().removeIf(out -> out instanceof OnCompletionDefinition oncompletiondefinition &&
+ !oncompletiondefinition.isRouteScoped());
}
@Override
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/ResequenceDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/ResequenceDefinition.java
index 078f1e727271..af4b976c609c 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/ResequenceDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/ResequenceDefinition.java
@@ -331,15 +331,17 @@ public class ResequenceDefinition extends OutputDefinition<ResequenceDefinition>
}
public BatchResequencerConfig getBatchConfig() {
- if (batchConfig == null && resequencerConfig != null && resequencerConfig instanceof BatchResequencerConfig) {
- return (BatchResequencerConfig) resequencerConfig;
+ if (batchConfig == null && resequencerConfig != null
+ && resequencerConfig instanceof BatchResequencerConfig batchresequencerconfig) {
+ return batchresequencerconfig;
}
return batchConfig;
}
public StreamResequencerConfig getStreamConfig() {
- if (streamConfig == null && resequencerConfig != null && resequencerConfig instanceof StreamResequencerConfig) {
- return (StreamResequencerConfig) resequencerConfig;
+ if (streamConfig == null && resequencerConfig != null
+ && resequencerConfig instanceof StreamResequencerConfig streamresequencerconfig) {
+ return streamresequencerconfig;
}
return streamConfig;
}
(camel) 11/41: (chores): modernize instanceof checks in camel-service
Posted by or...@apache.org.
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 <an...@gmail.com>
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);
(camel) 30/41: (chores): modernize instanceof checks in camel-mongodb
Posted by or...@apache.org.
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 d0ce524136d32de1c180dcbb00879b6f26b836e9
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:41:45 2026 +0000
(chores): modernize instanceof checks in camel-mongodb
---
.../java/org/apache/camel/component/mongodb/MongoDbComponent.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbComponent.java b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbComponent.java
index 4ee1c075dc7c..fec1d7195e25 100644
--- a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbComponent.java
+++ b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbComponent.java
@@ -72,8 +72,8 @@ public class MongoDbComponent extends DefaultComponent {
}
public static CamelMongoDbException wrapInCamelMongoDbException(Throwable t) {
- if (t instanceof CamelMongoDbException) {
- return (CamelMongoDbException) t;
+ if (t instanceof CamelMongoDbException camelMongoDbException) {
+ return camelMongoDbException;
} else {
return new CamelMongoDbException(t);
}
(camel) 03/41: (chores): modernize instanceof checks in camel-bean
Posted by or...@apache.org.
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 25ba10adf4df8bb07e670e1115f24a28b22512c4
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:31:08 2026 +0000
(chores): modernize instanceof checks in camel-bean
---
.../bean/AbstractCamelInvocationHandler.java | 8 ++++----
.../org/apache/camel/component/bean/MethodInfo.java | 20 ++++++++++----------
.../org/apache/camel/language/bean/BeanLanguage.java | 4 ++--
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/AbstractCamelInvocationHandler.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/AbstractCamelInvocationHandler.java
index 53f18b4855f9..5bc018b4ab01 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/AbstractCamelInvocationHandler.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/AbstractCamelInvocationHandler.java
@@ -239,8 +239,8 @@ public abstract class AbstractCamelInvocationHandler implements InvocationHandle
if (cause != null) {
Throwable found = findSuitableException(cause, method);
if (found != null) {
- if (found instanceof Exception) {
- throw (Exception) found;
+ if (found instanceof Exception exception) {
+ throw exception;
} else {
// wrap as exception
throw new CamelExchangeException("Error processing exchange", exchange, cause);
@@ -250,8 +250,8 @@ public abstract class AbstractCamelInvocationHandler implements InvocationHandle
if (cause instanceof RuntimeCamelException) {
// if the inner cause is a runtime exception we can throw it
// directly
- if (cause.getCause() instanceof RuntimeException) {
- throw (RuntimeException) cause.getCause();
+ if (cause.getCause() instanceof RuntimeException runtimeexception) {
+ throw runtimeexception;
}
throw cause;
}
diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
index c69ccd4db163..6254cfecf208 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
@@ -251,8 +251,8 @@ public class MethodInfo {
*/
public void setErrorHandler(Processor errorHandler) {
// special for @RecipientList which needs to be injected with error handler it should use
- if (recipientList instanceof ErrorHandlerAware) {
- ((ErrorHandlerAware) recipientList).setErrorHandler(errorHandler);
+ if (recipientList instanceof ErrorHandlerAware errorhandleraware) {
+ errorhandleraware.setErrorHandler(errorHandler);
}
}
@@ -309,9 +309,9 @@ public class MethodInfo {
Object result = invoke(method, pojo, arguments, exchange);
// the method may be a closure or chained method returning a callable which should be called
- if (result instanceof Callable) {
+ if (result instanceof Callable callable) {
LOG.trace("Method returned Callback which will be called: {}", result);
- Object callableResult = ((Callable) result).call();
+ Object callableResult = (callable).call();
if (callableResult != null) {
result = callableResult;
} else {
@@ -611,9 +611,9 @@ public class MethodInfo {
private Object[] evaluateParameterExpressions(Exchange exchange, Object body, Iterator<?> it) {
Object[] answer = new Object[expressions != null ? expressions.length : 1];
for (int i = 0; expressions == null || i < expressions.length; i++) {
- if (body instanceof StreamCache) {
+ if (body instanceof StreamCache streamcache2) {
// need to reset stream cache for each expression as you may access the message body in multiple parameters
- ((StreamCache) body).reset();
+ (streamcache2).reset();
}
// whether its vararg
@@ -654,9 +654,9 @@ public class MethodInfo {
*/
private Object evaluateVarargsParameterExpressions(Exchange exchange, Object body, Iterator<?> it) {
// special for varargs
- if (body instanceof StreamCache) {
+ if (body instanceof StreamCache streamcache) {
// need to reset stream cache for each expression as you may access the message body in multiple parameters
- ((StreamCache) body).reset();
+ (streamcache).reset();
}
List<Object> answer = new ArrayList<>();
int i = 0;
@@ -758,8 +758,8 @@ public class MethodInfo {
if (valid) {
// we need to unquote String parameters, as the enclosing quotes is there to denote a parameter value
- if (parameterValue instanceof String) {
- parameterValue = StringHelper.removeLeadingAndEndingQuotes((String) parameterValue);
+ if (parameterValue instanceof String string) {
+ parameterValue = StringHelper.removeLeadingAndEndingQuotes(string);
}
if (varargs) {
// use the value as-is
diff --git a/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanLanguage.java b/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanLanguage.java
index 2939f1e8b132..b87aa0b53025 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanLanguage.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanLanguage.java
@@ -134,8 +134,8 @@ public class BeanLanguage extends TypedLanguageSupport implements ScriptingLangu
throw new IllegalArgumentException("Bean language requires bean, beanType, or ref argument");
}
Object scope = property(Object.class, properties, 5, null);
- if (scope instanceof BeanScope) {
- answer.setScope((BeanScope) scope);
+ if (scope instanceof BeanScope beanscope) {
+ answer.setScope(beanscope);
} else if (scope != null) {
answer.setScope(BeanScope.valueOf(scope.toString()));
}
(camel) 04/41: (chores): modernize instanceof checks in camel-beanio
Posted by or...@apache.org.
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 a1820b681716e765871218faf834ad95027f1fa9
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:31:12 2026 +0000
(chores): modernize instanceof checks in camel-beanio
---
.../java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java | 4 ++--
.../main/java/org/apache/camel/dataformat/beanio/BeanIOHelper.java | 3 +--
.../java/org/apache/camel/dataformat/beanio/BeanIOSplitter.java | 7 +++----
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java
index 293c7494ed65..abb3aed9195a 100644
--- a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java
+++ b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java
@@ -201,8 +201,8 @@ public class BeanIODataFormat extends ServiceSupport implements DataFormat, Data
in.setErrorHandler(errorHandler);
Object readObject;
while ((readObject = in.read()) != null) {
- if (readObject instanceof BeanIOHeader) {
- exchange.getOut().getHeaders().putAll(((BeanIOHeader) readObject).getHeaders());
+ if (readObject instanceof BeanIOHeader beanioheader) {
+ exchange.getOut().getHeaders().putAll(beanioheader.getHeaders());
}
results.add(readObject);
}
diff --git a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOHelper.java b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOHelper.java
index 2273ef9ebac2..192bab750c62 100644
--- a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOHelper.java
+++ b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOHelper.java
@@ -51,8 +51,7 @@ public final class BeanIOHelper {
}
// if the error handler extends BeanIOErrorHandler then its prototype scoped
// and then inject the current exchange and init
- if (answer instanceof BeanIOErrorHandler) {
- BeanIOErrorHandler eh = (BeanIOErrorHandler) answer;
+ if (answer instanceof BeanIOErrorHandler eh) {
eh.setConfiguration(configuration);
eh.setExchange(exchange);
eh.setResults(results);
diff --git a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOSplitter.java b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOSplitter.java
index 5ef9e1feafe9..47787eff4e8b 100644
--- a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOSplitter.java
+++ b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOSplitter.java
@@ -87,11 +87,10 @@ public class BeanIOSplitter implements Expression {
}
BeanReader beanReader = null;
- if (body instanceof WrappedFile) {
- body = ((WrappedFile) body).getFile();
+ if (body instanceof WrappedFile wrappedfile) {
+ body = wrappedfile.getFile();
}
- if (body instanceof File) {
- File file = (File) body;
+ if (body instanceof File file) {
beanReader = factory.createReader(getStreamName(), file);
}
if (beanReader == null) {
(camel) 01/41: (chores): modernize instanceof checks in camel-mock
Posted by or...@apache.org.
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 27afdf8e6012576b19672f9b2da66577739d9e48
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 09:36:59 2026 +0000
(chores): modernize instanceof checks in camel-mock
---
.../apache/camel/component/mock/MockValueBuilder.java | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
index 9b5fe415623a..d33354721d96 100644
--- a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
+++ b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
@@ -643,8 +643,7 @@ public class MockValueBuilder implements Expression, Predicate {
// Primitives that are valid JSON values
if (value instanceof String || value instanceof Number || value instanceof Boolean) {
// For strings, we need to check if it's a JSON string or a plain string
- if (value instanceof String) {
- String str = (String) value;
+ if (value instanceof String str) {
str = str.trim();
// Check if it looks like JSON
if (str.startsWith("{") || str.startsWith("[") || str.equals("null")
@@ -662,16 +661,16 @@ public class MockValueBuilder implements Expression, Predicate {
}
// byte[] input
- if (value instanceof byte[]) {
- try (InputStream is = new ByteArrayInputStream((byte[]) value);
+ if (value instanceof byte[] byteArray) {
+ try (InputStream is = new ByteArrayInputStream(byteArray);
Reader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
return Jsoner.deserialize(reader);
}
}
// InputStream input
- if (value instanceof InputStream) {
- try (Reader reader = new InputStreamReader((InputStream) value, StandardCharsets.UTF_8)) {
+ if (value instanceof InputStream inputstream) {
+ try (Reader reader = new InputStreamReader(inputstream, StandardCharsets.UTF_8)) {
return Jsoner.deserialize(reader);
}
}
@@ -708,8 +707,8 @@ public class MockValueBuilder implements Expression, Predicate {
}
// JsonObject comparison
- if (expected instanceof JsonObject && actual instanceof JsonObject) {
- return jsonObjectEquals((JsonObject) expected, (JsonObject) actual, ignoreOrder);
+ if (expected instanceof JsonObject jsonobject && actual instanceof JsonObject) {
+ return jsonObjectEquals(jsonobject, (JsonObject) actual, ignoreOrder);
}
// Map comparison (in case of deserialized maps)
@@ -718,8 +717,8 @@ public class MockValueBuilder implements Expression, Predicate {
}
// JsonArray comparison
- if (expected instanceof JsonArray && actual instanceof JsonArray) {
- return jsonArrayEquals((JsonArray) expected, (JsonArray) actual, ignoreOrder);
+ if (expected instanceof JsonArray jsonarray && actual instanceof JsonArray) {
+ return jsonArrayEquals(jsonarray, (JsonArray) actual, ignoreOrder);
}
// List comparison (in case of deserialized lists)
(camel) 29/41: (chores): modernize instanceof checks in camel-hazelcast
Posted by or...@apache.org.
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 091bce55cad5a0bb9d2f53f54017c5dcd87e895c
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:29:10 2026 +0000
(chores): modernize instanceof checks in camel-hazelcast
---
.../apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java
index ff7ac6648a0d..fd811f305e81 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java
@@ -94,8 +94,8 @@ public class HazelcastSedaConsumer extends DefaultConsumer implements Runnable {
final Object body = queue.poll(endpoint.getConfiguration().getPollTimeout(), TimeUnit.MILLISECONDS);
if (body != null) {
- if (body instanceof DefaultExchangeHolder) {
- DefaultExchangeHolder.unmarshal(exchange, (DefaultExchangeHolder) body);
+ if (body instanceof DefaultExchangeHolder defaultExchangeHolder) {
+ DefaultExchangeHolder.unmarshal(exchange, defaultExchangeHolder);
} else {
exchange.getIn().setBody(body);
}
(camel) 22/41: (chores): modernize instanceof checks in camel-amqp
Posted by or...@apache.org.
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 3b2c2a971c6316d82d8d8278bd7070666f5cbe65
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:15:42 2026 +0000
(chores): modernize instanceof checks in camel-amqp
---
.../src/main/java/org/apache/camel/component/amqp/AMQPJmsBinding.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPJmsBinding.java b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPJmsBinding.java
index 04893fb47160..6f479eb1aad4 100644
--- a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPJmsBinding.java
+++ b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPJmsBinding.java
@@ -72,8 +72,8 @@ public class AMQPJmsBinding extends JmsBinding {
private AmqpJmsMessageFacade getMessageFacade(Message message) {
if (message instanceof JmsMessage jmsMessage) {
- if (jmsMessage.getFacade() instanceof AmqpJmsMessageFacade) {
- return (AmqpJmsMessageFacade) jmsMessage.getFacade();
+ if (jmsMessage.getFacade() instanceof AmqpJmsMessageFacade amqpJmsMessageFacade) {
+ return amqpJmsMessageFacade;
}
}
return null;
(camel) 26/41: (chores): modernize instanceof checks in camel-cron
Posted by or...@apache.org.
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 3f77303a47fc9cba37dcf1e389d3c7ce896cb766
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:25:04 2026 +0000
(chores): modernize instanceof checks in camel-cron
---
.../src/main/java/org/apache/camel/component/cron/CronComponent.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/components/camel-cron/src/main/java/org/apache/camel/component/cron/CronComponent.java b/components/camel-cron/src/main/java/org/apache/camel/component/cron/CronComponent.java
index 8d66b9752efd..1bad1cfd5de0 100644
--- a/components/camel-cron/src/main/java/org/apache/camel/component/cron/CronComponent.java
+++ b/components/camel-cron/src/main/java/org/apache/camel/component/cron/CronComponent.java
@@ -64,8 +64,7 @@ public class CronComponent extends DefaultComponent {
// create delegate and set on endpoint
Endpoint delegate = this.service.createEndpoint(configuration);
answer.setDelegate(delegate);
- if (delegate instanceof DefaultEndpoint) {
- DefaultEndpoint de = (DefaultEndpoint) delegate;
+ if (delegate instanceof DefaultEndpoint de) {
de.setAutowiredEnabled(answer.isAutowiredEnabled());
de.setBridgeErrorHandler(answer.isBridgeErrorHandler());
de.setExceptionHandler(answer.getExceptionHandler());
(camel) 23/41: (chores): modernize instanceof checks in camel-bindy
Posted by or...@apache.org.
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 05d4dcf801c6cedd0dfdc5acdd49eabacfcfeff7
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:16:55 2026 +0000
(chores): modernize instanceof checks in camel-bindy
---
.../org/apache/camel/dataformat/bindy/format/NumberPatternFormat.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/NumberPatternFormat.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/NumberPatternFormat.java
index f35693570407..552b4c0ca154 100644
--- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/NumberPatternFormat.java
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/NumberPatternFormat.java
@@ -73,8 +73,7 @@ public abstract class NumberPatternFormat<T> implements PatternFormat<T> {
}
NumberFormat format = NumberFormat.getNumberInstance(locale);
- if (format instanceof DecimalFormat) {
- DecimalFormat df = (DecimalFormat) format;
+ if (format instanceof DecimalFormat df) {
if (decimalSeparator != null && groupingSeparator != null) {
if (!decimalSeparator.isEmpty() && !groupingSeparator.isEmpty()) {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);
(camel) 06/41: (chores): modernize instanceof checks in camel-slack
Posted by or...@apache.org.
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 aacf00397d42cdb3d609c60c1c70d3c3603d313c
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:40:48 2026 +0000
(chores): modernize instanceof checks in camel-slack
---
.../org/apache/camel/component/slack/SlackProducer.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackProducer.java b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackProducer.java
index 58dd81a562b8..1768f82bb2f7 100644
--- a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackProducer.java
+++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackProducer.java
@@ -75,10 +75,10 @@ public class SlackProducer extends DefaultAsyncProducer {
Object payload = exchange.getIn().getBody();
try {
- if (payload instanceof SlackMessage) {
- response = sendLegacySlackMessage((SlackMessage) payload);
- } else if (payload instanceof Message) {
- response = sendMessage((Message) payload);
+ if (payload instanceof SlackMessage slackmessage2) {
+ response = sendLegacySlackMessage(slackmessage2);
+ } else if (payload instanceof Message message2) {
+ response = sendMessage(message2);
} else {
SlackMessage slackMessage = new SlackMessage();
slackMessage.setText(exchange.getIn().getBody(String.class));
@@ -121,10 +121,10 @@ public class SlackProducer extends DefaultAsyncProducer {
private boolean sendMessageByWebhookURL(Exchange exchange, AsyncCallback callback) {
String json;
Object payload = exchange.getIn().getBody();
- if (payload instanceof SlackMessage) {
- json = GSON.toJson(addEndPointOptions((SlackMessage) payload));
- } else if (payload instanceof Message) {
- json = GSON.toJson(addEndPointOptions((Message) payload));
+ if (payload instanceof SlackMessage slackmessage) {
+ json = GSON.toJson(addEndPointOptions(slackmessage));
+ } else if (payload instanceof Message message) {
+ json = GSON.toJson(addEndPointOptions(message));
} else {
SlackMessage slackMessage = new SlackMessage();
slackMessage.setText(exchange.getIn().getBody(String.class));
(camel) 28/41: (chores): modernize instanceof checks in camel-exec
Posted by or...@apache.org.
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 d9d2cb2500f93b1fd2358d668afb884f477781ef
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:27:26 2026 +0000
(chores): modernize instanceof checks in camel-exec
---
.../apache/camel/component/exec/impl/DefaultExecCommandExecutor.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/impl/DefaultExecCommandExecutor.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/impl/DefaultExecCommandExecutor.java
index de029d98a8fb..1f94a79ca816 100644
--- a/components/camel-exec/src/main/java/org/apache/camel/component/exec/impl/DefaultExecCommandExecutor.java
+++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/impl/DefaultExecCommandExecutor.java
@@ -88,9 +88,9 @@ public class DefaultExecCommandExecutor implements ExecCommandExecutor {
InputStream stderr = err.size() == 0 ? null : new ByteArrayInputStream(err.toByteArray());
int exitValue = 0; // use 0 as exit value as the executor didn't return the value
- if (executor instanceof ExecDefaultExecutor) {
+ if (executor instanceof ExecDefaultExecutor execDefaultExecutor) {
// get the exit value from the executor as it captures this to work around the common-exec bug
- exitValue = ((ExecDefaultExecutor) executor).getExitValue();
+ exitValue = execDefaultExecutor.getExitValue();
}
// workaround to Disabled if the stream was already closes due some race condition in commons-exec
(camel) 33/41: (chores): modernize instanceof checks in camel-jq
Posted by or...@apache.org.
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 de9dd13559c6ede93133682704ed74173b585e1f
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:46:00 2026 +0000
(chores): modernize instanceof checks in camel-jq
---
.../src/main/java/org/apache/camel/language/jq/JqExpression.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/camel-jq/src/main/java/org/apache/camel/language/jq/JqExpression.java b/components/camel-jq/src/main/java/org/apache/camel/language/jq/JqExpression.java
index 9501c72fa63d..4250ba9bd4e7 100644
--- a/components/camel-jq/src/main/java/org/apache/camel/language/jq/JqExpression.java
+++ b/components/camel-jq/src/main/java/org/apache/camel/language/jq/JqExpression.java
@@ -131,8 +131,8 @@ public class JqExpression extends ExpressionAdapter implements ExpressionResultT
public boolean matches(Exchange exchange) {
final Object value = evaluate(exchange, Object.class);
- if (value instanceof BooleanNode) {
- return ((BooleanNode) value).asBoolean();
+ if (value instanceof BooleanNode booleanNode) {
+ return booleanNode.asBoolean();
}
if (value instanceof Collection) {
return !((Collection<?>) value).isEmpty();
(camel) 35/41: (chores): modernize instanceof checks in camel-printer
Posted by or...@apache.org.
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 4a144bd04311ef859178da2b5477f216cf95c14f
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:47:53 2026 +0000
(chores): modernize instanceof checks in camel-printer
---
.../main/java/org/apache/camel/component/printer/PrinterProducer.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java b/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
index a91c5ee0094e..1adc6fd4807b 100644
--- a/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
+++ b/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
@@ -100,8 +100,7 @@ public class PrinterProducer extends DefaultProducer {
return null;
} else {
for (Media media : medias) {
- if (media instanceof MediaTray) {
- MediaTray mediaTray = (MediaTray) media;
+ if (media instanceof MediaTray mediaTray) {
String trayName = mediaTray.toString().trim();
if (trayName.contains(" ")) {
trayName = trayName.replace(' ', '_');
(camel) 02/41: (chores): modernize instanceof checks in camel-route-parser
Posted by or...@apache.org.
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 0dec67585276c33ab85e7c49ac397f2fdd302b1e
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:25:55 2026 +0000
(chores): modernize instanceof checks in camel-route-parser
---
.../camel/parser/helper/CamelJavaParserHelper.java | 20 +++++------
.../helper/CamelJavaRestDslParserHelper.java | 40 +++++++++++-----------
.../parser/helper/CamelJavaTreeParserHelper.java | 40 +++++++++++-----------
.../apache/camel/parser/helper/CamelXmlHelper.java | 4 +--
.../apache/camel/parser/helper/ParserCommon.java | 8 ++---
5 files changed, 56 insertions(+), 56 deletions(-)
diff --git a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
index c283bf32c4d1..21541f0fef4e 100644
--- a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
+++ b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
@@ -344,8 +344,8 @@ public final class CamelJavaParserHelper {
return;
}
}
- if (fields && arg instanceof SimpleName) {
- FieldSource<JavaClassSource> field = ParserCommon.getField(clazz, block, (SimpleName) arg);
+ if (fields && arg instanceof SimpleName simplename) {
+ FieldSource<JavaClassSource> field = ParserCommon.getField(clazz, block, simplename);
if (field != null) {
// find the endpoint uri from the annotation
AnnotationSource<JavaClassSource> annotation = field.getAnnotation("org.apache.camel.EndpointInject");
@@ -360,8 +360,8 @@ public final class CamelJavaParserHelper {
} else {
// the field may be initialized using variables, so we need to evaluate those expressions
Object fi = field.getInternal();
- if (fi instanceof VariableDeclaration) {
- Expression exp = ((VariableDeclaration) fi).getInitializer();
+ if (fi instanceof VariableDeclaration variabledeclaration) {
+ Expression exp = (variabledeclaration).getInitializer();
String uri = CamelJavaParserHelper.getLiteralValue(clazz, block, exp);
if (!Strings.isNullOrEmpty(uri)) {
// we want the position of the field, and not in the route
@@ -444,8 +444,8 @@ public final class CamelJavaParserHelper {
if (list != null && list.size() == 1) {
ASTNode o = (ASTNode) list.get(0);
ASTNode p = o.getParent();
- if (p instanceof MethodInvocation) {
- String pName = ((MethodInvocation) p).getName().getIdentifier();
+ if (p instanceof MethodInvocation methodinvocation) {
+ String pName = (methodinvocation).getName().getIdentifier();
if (language.equals(pName)) {
// okay find the parent of the language which is the method that uses the language
parent = (Expression) p.getParent();
@@ -490,8 +490,8 @@ public final class CamelJavaParserHelper {
public static String getLiteralValue(JavaClassSource clazz, Block block, Expression expression) {
// unwrap parenthesis
- if (expression instanceof ParenthesizedExpression) {
- expression = ((ParenthesizedExpression) expression).getExpression();
+ if (expression instanceof ParenthesizedExpression parenthesizedexpression) {
+ expression = (parenthesizedexpression).getExpression();
}
if (expression instanceof StringLiteral stringLiteral) {
@@ -518,8 +518,8 @@ public final class CamelJavaParserHelper {
return "{{" + name + "}}";
}
- if (expression instanceof SimpleName) {
- FieldSource<JavaClassSource> field = ParserCommon.getField(clazz, block, (SimpleName) expression);
+ if (expression instanceof SimpleName simplename) {
+ FieldSource<JavaClassSource> field = ParserCommon.getField(clazz, block, simplename);
if (field != null) {
// is the field annotated with a Camel endpoint
if (field.getAnnotations() != null) {
diff --git a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaRestDslParserHelper.java b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaRestDslParserHelper.java
index a03de3df2e39..b3ae8e7a211a 100644
--- a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaRestDslParserHelper.java
+++ b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaRestDslParserHelper.java
@@ -175,8 +175,8 @@ public final class CamelJavaRestDslParserHelper {
Expression sub = exp;
while (sub instanceof MethodInvocation methodInvocation) {
sub = methodInvocation.getExpression();
- if (sub instanceof MethodInvocation) {
- Expression parent = ((MethodInvocation) sub).getExpression();
+ if (sub instanceof MethodInvocation methodinvocation) {
+ Expression parent = (methodinvocation).getExpression();
if (parent == null) {
break;
}
@@ -420,10 +420,10 @@ public final class CamelJavaRestDslParserHelper {
// find out if this is from a Camel route (eg from, route etc.)
Expression sub = mi;
- while (sub instanceof MethodInvocation) {
- sub = ((MethodInvocation) sub).getExpression();
- if (sub instanceof MethodInvocation) {
- name = ((MethodInvocation) sub).getName().getIdentifier();
+ while (sub instanceof MethodInvocation methodinvocation) {
+ sub = methodinvocation.getExpression();
+ if (sub instanceof MethodInvocation mi2) {
+ name = mi2.getName().getIdentifier();
if (parentName.equals(name)) {
return true;
}
@@ -467,8 +467,8 @@ public final class CamelJavaRestDslParserHelper {
private static FieldSource<JavaClassSource> findFieldInBlock(JavaClassSource clazz, Block block, String fieldName) {
for (Object statement : block.statements()) {
// try local statements first in the block
- if (statement instanceof VariableDeclarationStatement) {
- final Type type = ((VariableDeclarationStatement) statement).getType();
+ if (statement instanceof VariableDeclarationStatement variabledeclarationstatement) {
+ final Type type = (variabledeclarationstatement).getType();
for (Object obj : ((VariableDeclarationStatement) statement).fragments()) {
if (obj instanceof VariableDeclarationFragment fragment) {
SimpleName name = fragment.getName();
@@ -507,16 +507,16 @@ public final class CamelJavaRestDslParserHelper {
public static String getLiteralValue(JavaClassSource clazz, Block block, Expression expression) {
// unwrap parenthesis
- if (expression instanceof ParenthesizedExpression) {
- expression = ((ParenthesizedExpression) expression).getExpression();
+ if (expression instanceof ParenthesizedExpression parenthesizedexpression) {
+ expression = (parenthesizedexpression).getExpression();
}
- if (expression instanceof StringLiteral) {
- return ((StringLiteral) expression).getLiteralValue();
- } else if (expression instanceof BooleanLiteral) {
- return String.valueOf(((BooleanLiteral) expression).booleanValue());
- } else if (expression instanceof NumberLiteral) {
- return ((NumberLiteral) expression).getToken();
+ if (expression instanceof StringLiteral stringliteral) {
+ return (stringliteral).getLiteralValue();
+ } else if (expression instanceof BooleanLiteral booleanliteral) {
+ return String.valueOf((booleanliteral).booleanValue());
+ } else if (expression instanceof NumberLiteral numberliteral) {
+ return (numberliteral).getToken();
} else if (expression instanceof TextBlock textBlock) {
return textBlock.getLiteralValue();
}
@@ -532,8 +532,8 @@ public final class CamelJavaRestDslParserHelper {
return qn.getName().getIdentifier();
}
- if (expression instanceof SimpleName) {
- FieldSource<JavaClassSource> field = getField(clazz, block, (SimpleName) expression);
+ if (expression instanceof SimpleName simplename) {
+ FieldSource<JavaClassSource> field = getField(clazz, block, simplename);
if (field != null) {
// is the field annotated with a Camel endpoint
if (field.getAnnotations() != null) {
@@ -629,8 +629,8 @@ public final class CamelJavaRestDslParserHelper {
private static boolean isNumericOperator(JavaClassSource clazz, Block block, Expression expression) {
if (expression instanceof NumberLiteral) {
return true;
- } else if (expression instanceof SimpleName) {
- FieldSource<JavaClassSource> field = getField(clazz, block, (SimpleName) expression);
+ } else if (expression instanceof SimpleName simplename) {
+ FieldSource<JavaClassSource> field = getField(clazz, block, simplename);
if (field != null) {
return field.getType().isType("int") || field.getType().isType("long")
|| field.getType().isType("Integer") || field.getType().isType("Long");
diff --git a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaTreeParserHelper.java b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaTreeParserHelper.java
index 457260319865..e426cc4b8663 100644
--- a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaTreeParserHelper.java
+++ b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaTreeParserHelper.java
@@ -162,10 +162,10 @@ public final class CamelJavaTreeParserHelper {
// find out if this is from a Camel route (eg from, route etc.)
Expression sub = exp;
- while (sub instanceof MethodInvocation) {
- sub = ((MethodInvocation) sub).getExpression();
- if (sub instanceof MethodInvocation) {
- Expression parent = ((MethodInvocation) sub).getExpression();
+ while (sub instanceof MethodInvocation methodinvocation) {
+ sub = methodinvocation.getExpression();
+ if (sub instanceof MethodInvocation mi2) {
+ Expression parent = mi2.getExpression();
if (parent == null) {
break;
}
@@ -272,23 +272,23 @@ public final class CamelJavaTreeParserHelper {
public static String getLiteralValue(JavaClassSource clazz, Block block, Expression expression) {
// unwrap parenthesis
- if (expression instanceof ParenthesizedExpression) {
- expression = ((ParenthesizedExpression) expression).getExpression();
+ if (expression instanceof ParenthesizedExpression parenthesizedexpression) {
+ expression = (parenthesizedexpression).getExpression();
}
- if (expression instanceof StringLiteral) {
- return ((StringLiteral) expression).getLiteralValue();
- } else if (expression instanceof BooleanLiteral) {
- return String.valueOf(((BooleanLiteral) expression).booleanValue());
- } else if (expression instanceof NumberLiteral) {
- return ((NumberLiteral) expression).getToken();
+ if (expression instanceof StringLiteral stringliteral) {
+ return (stringliteral).getLiteralValue();
+ } else if (expression instanceof BooleanLiteral booleanliteral) {
+ return String.valueOf((booleanliteral).booleanValue());
+ } else if (expression instanceof NumberLiteral numberliteral) {
+ return (numberliteral).getToken();
} else if (expression instanceof TextBlock textBlock) {
return textBlock.getLiteralValue();
}
// if it's a method invocation then add a dummy value assuming the method invocation will return a valid response
- if (expression instanceof MethodInvocation) {
- String name = ((MethodInvocation) expression).getName().getIdentifier();
+ if (expression instanceof MethodInvocation methodinvocation) {
+ String name = (methodinvocation).getName().getIdentifier();
return "{{" + name + "}}";
}
@@ -300,8 +300,8 @@ public final class CamelJavaTreeParserHelper {
return "{{" + name + "}}";
}
- if (expression instanceof SimpleName) {
- FieldSource<JavaClassSource> field = ParserCommon.getField(clazz, block, (SimpleName) expression);
+ if (expression instanceof SimpleName simplename) {
+ FieldSource<JavaClassSource> field = ParserCommon.getField(clazz, block, simplename);
if (field != null) {
// is the field annotated with a Camel endpoint
if (field.getAnnotations() != null) {
@@ -309,10 +309,10 @@ public final class CamelJavaTreeParserHelper {
boolean valid = "org.apache.camel.EndpointInject".equals(ann.getQualifiedName());
if (valid) {
Expression exp = (Expression) ann.getInternal();
- if (exp instanceof SingleMemberAnnotation) {
- exp = ((SingleMemberAnnotation) exp).getValue();
- } else if (exp instanceof NormalAnnotation) {
- List<?> values = ((NormalAnnotation) exp).values();
+ if (exp instanceof SingleMemberAnnotation singlememberannotation) {
+ exp = (singlememberannotation).getValue();
+ } else if (exp instanceof NormalAnnotation normalannotation) {
+ List<?> values = (normalannotation).values();
for (Object value : values) {
MemberValuePair pair = (MemberValuePair) value;
if ("uri".equals(pair.getName().toString())) {
diff --git a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
index ec7e0bc4a988..b9e222f2085e 100644
--- a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
+++ b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
@@ -188,8 +188,8 @@ public final class CamelXmlHelper {
Element selectedElement = null;
if (root != null) {
Node selectedNode = findCamelNodeInDocument(root, key);
- if (selectedNode instanceof Element) {
- selectedElement = (Element) selectedNode;
+ if (selectedNode instanceof Element element) {
+ selectedElement = element;
}
}
return selectedElement;
diff --git a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/ParserCommon.java b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/ParserCommon.java
index 3f3d97607a85..086d9cea93e0 100644
--- a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/ParserCommon.java
+++ b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/ParserCommon.java
@@ -82,8 +82,8 @@ public final class ParserCommon {
if (node instanceof MethodDeclaration) {
node = node.getParent();
}
- if (node instanceof AnonymousClassDeclaration) {
- List<?> declarations = ((AnonymousClassDeclaration) node).bodyDeclarations();
+ if (node instanceof AnonymousClassDeclaration anonymousclassdeclaration) {
+ List<?> declarations = (anonymousclassdeclaration).bodyDeclarations();
for (Object dec : declarations) {
if (dec instanceof FieldDeclaration fd) {
final Type type = fd.getType();
@@ -118,8 +118,8 @@ public final class ParserCommon {
public static boolean isNumericOperator(JavaClassSource clazz, Block block, Expression expression) {
if (expression instanceof NumberLiteral) {
return true;
- } else if (expression instanceof SimpleName) {
- FieldSource<JavaClassSource> field = getField(clazz, block, (SimpleName) expression);
+ } else if (expression instanceof SimpleName simplename) {
+ FieldSource<JavaClassSource> field = getField(clazz, block, simplename);
if (field != null) {
return field.getType().isType("int") || field.getType().isType("long")
|| field.getType().isType("Integer") || field.getType().isType("Long");
(camel) 16/41: (chores): modernize instanceof checks in camel-quartz
Posted by or...@apache.org.
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 cd0e6dd80893614732c76ca411e8837c2951de10
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:54:26 2026 +0000
(chores): modernize instanceof checks in camel-quartz
---
.../main/java/org/apache/camel/component/quartz/CamelJob.java | 11 +++++------
.../org/apache/camel/component/quartz/QuartzEndpoint.java | 11 +++--------
.../pollconsumer/quartz/QuartzScheduledPollConsumerJob.java | 4 ++--
.../quartz/QuartzScheduledPollConsumerScheduler.java | 8 ++------
.../org/apache/camel/routepolicy/quartz/ScheduledJob.java | 4 ++--
5 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java
index d4913eb43ec0..7cd525cb5ec0 100644
--- a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java
+++ b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java
@@ -96,8 +96,8 @@ public class CamelJob implements Job, InterruptableJob {
}
// and rethrow to let quartz handle it
- if (e instanceof JobExecutionException) {
- throw (JobExecutionException) e;
+ if (e instanceof JobExecutionException jobexecutionexception) {
+ throw jobexecutionexception;
}
throw new JobExecutionException(e);
}
@@ -156,11 +156,10 @@ public class CamelJob implements Job, InterruptableJob {
// as we prefer to use the existing endpoint from the routes
for (Route route : camelContext.getRoutes()) {
Endpoint endpoint = route.getEndpoint();
- if (endpoint instanceof DelegateEndpoint) {
- endpoint = ((DelegateEndpoint) endpoint).getEndpoint();
+ if (endpoint instanceof DelegateEndpoint delegateendpoint) {
+ endpoint = delegateendpoint.getEndpoint();
}
- if (endpoint instanceof QuartzEndpoint) {
- QuartzEndpoint quartzEndpoint = (QuartzEndpoint) endpoint;
+ if (endpoint instanceof QuartzEndpoint quartzEndpoint) {
TriggerKey checkTriggerKey = quartzEndpoint.getTriggerKey();
if (LOG.isTraceEnabled()) {
LOG.trace("Checking route endpoint={} with checkTriggerKey={}", quartzEndpoint, checkTriggerKey);
diff --git a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java
index aa228136170d..92b9dba5e2ac 100644
--- a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java
+++ b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java
@@ -448,13 +448,9 @@ public class QuartzEndpoint extends DefaultEndpoint {
}
private boolean hasTriggerChanged(Trigger oldTrigger, Trigger newTrigger) {
- if (newTrigger instanceof CronTrigger && oldTrigger instanceof CronTrigger) {
- CronTrigger newCron = (CronTrigger) newTrigger;
- CronTrigger oldCron = (CronTrigger) oldTrigger;
+ if (newTrigger instanceof CronTrigger newCron && oldTrigger instanceof CronTrigger oldCron) {
return !newCron.getCronExpression().equals(oldCron.getCronExpression());
- } else if (newTrigger instanceof SimpleTrigger && oldTrigger instanceof SimpleTrigger) {
- SimpleTrigger newSimple = (SimpleTrigger) newTrigger;
- SimpleTrigger oldSimple = (SimpleTrigger) oldTrigger;
+ } else if (newTrigger instanceof SimpleTrigger newSimple && oldTrigger instanceof SimpleTrigger oldSimple) {
return newSimple.getRepeatInterval() != oldSimple.getRepeatInterval()
|| newSimple.getRepeatCount() != oldSimple.getRepeatCount();
} else {
@@ -464,8 +460,7 @@ public class QuartzEndpoint extends DefaultEndpoint {
private void ensureNoDupTriggerKey() {
for (Route route : getCamelContext().getRoutes()) {
- if (route.getEndpoint() instanceof QuartzEndpoint) {
- QuartzEndpoint quartzEndpoint = (QuartzEndpoint) route.getEndpoint();
+ if (route.getEndpoint() instanceof QuartzEndpoint quartzEndpoint) {
TriggerKey checkTriggerKey = quartzEndpoint.getTriggerKey();
if (triggerKey.equals(checkTriggerKey)) {
throw new IllegalArgumentException("Trigger key " + triggerKey + " is already in use by " + quartzEndpoint);
diff --git a/components/camel-quartz/src/main/java/org/apache/camel/pollconsumer/quartz/QuartzScheduledPollConsumerJob.java b/components/camel-quartz/src/main/java/org/apache/camel/pollconsumer/quartz/QuartzScheduledPollConsumerJob.java
index f60f2959703f..a90724329727 100644
--- a/components/camel-quartz/src/main/java/org/apache/camel/pollconsumer/quartz/QuartzScheduledPollConsumerJob.java
+++ b/components/camel-quartz/src/main/java/org/apache/camel/pollconsumer/quartz/QuartzScheduledPollConsumerJob.java
@@ -47,8 +47,8 @@ public class QuartzScheduledPollConsumerJob extends CamelJob {
for (Route route : camelContext.getRoutes()) {
if (route.getId().equals(routeId)) {
Consumer consumer = route.getConsumer();
- if (consumer instanceof Runnable) {
- task = (Runnable) consumer;
+ if (consumer instanceof Runnable runnable) {
+ task = runnable;
break;
}
}
diff --git a/components/camel-quartz/src/main/java/org/apache/camel/pollconsumer/quartz/QuartzScheduledPollConsumerScheduler.java b/components/camel-quartz/src/main/java/org/apache/camel/pollconsumer/quartz/QuartzScheduledPollConsumerScheduler.java
index f6dd1f09527f..23e11316d1ee 100644
--- a/components/camel-quartz/src/main/java/org/apache/camel/pollconsumer/quartz/QuartzScheduledPollConsumerScheduler.java
+++ b/components/camel-quartz/src/main/java/org/apache/camel/pollconsumer/quartz/QuartzScheduledPollConsumerScheduler.java
@@ -326,13 +326,9 @@ public class QuartzScheduledPollConsumerScheduler extends ServiceSupport
}
private boolean hasTriggerChanged(Trigger oldTrigger, Trigger newTrigger) {
- if (newTrigger instanceof CronTrigger && oldTrigger instanceof CronTrigger) {
- CronTrigger newCron = (CronTrigger) newTrigger;
- CronTrigger oldCron = (CronTrigger) oldTrigger;
+ if (newTrigger instanceof CronTrigger newCron && oldTrigger instanceof CronTrigger oldCron) {
return !newCron.getCronExpression().equals(oldCron.getCronExpression());
- } else if (newTrigger instanceof SimpleTrigger && oldTrigger instanceof SimpleTrigger) {
- SimpleTrigger newSimple = (SimpleTrigger) newTrigger;
- SimpleTrigger oldSimple = (SimpleTrigger) oldTrigger;
+ } else if (newTrigger instanceof SimpleTrigger newSimple && oldTrigger instanceof SimpleTrigger oldSimple) {
return newSimple.getRepeatInterval() != oldSimple.getRepeatInterval()
|| newSimple.getRepeatCount() != oldSimple.getRepeatCount();
} else {
diff --git a/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java b/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java
index 48ed393d9814..e4dbd36e997d 100644
--- a/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java
+++ b/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java
@@ -47,8 +47,8 @@ public class ScheduledJob implements Job, Serializable, ScheduledRoutePolicyCons
List<RoutePolicy> policyList = storedRoute.getRoutePolicyList();
for (RoutePolicy policy : policyList) {
try {
- if (policy instanceof ScheduledRoutePolicy) {
- ((ScheduledRoutePolicy) policy).onJobExecute(storedAction, storedRoute);
+ if (policy instanceof ScheduledRoutePolicy scheduledroutepolicy) {
+ scheduledroutepolicy.onJobExecute(storedAction, storedRoute);
}
} catch (Exception e) {
throw new JobExecutionException(
(camel) 20/41: (chores): modernize instanceof checks in camel-activemq6
Posted by or...@apache.org.
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 e74898f2e3454688b419058c9a7e215bd36022a0
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:13:28 2026 +0000
(chores): modernize instanceof checks in camel-activemq6
---
.../org/apache/camel/component/activemq6/ActiveMQComponent.java | 4 ++--
.../apache/camel/component/activemq6/ActiveMQConfiguration.java | 4 ++--
.../component/activemq6/OriginalDestinationPropagateStrategy.java | 4 ++--
.../component/activemq6/converter/ActiveMQMessageConverter.java | 8 ++++----
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQComponent.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQComponent.java
index a3c263d25b25..c75b4fc8ed70 100644
--- a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQComponent.java
+++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQComponent.java
@@ -78,8 +78,8 @@ public class ActiveMQComponent extends JmsComponent {
*/
public static ActiveMQComponent activeMQComponent(String brokerURL) {
ActiveMQComponent answer = new ActiveMQComponent();
- if (answer.getConfiguration() instanceof ActiveMQConfiguration) {
- ((ActiveMQConfiguration) answer.getConfiguration()).setBrokerURL(brokerURL);
+ if (answer.getConfiguration() instanceof ActiveMQConfiguration activeMQConfiguration) {
+ activeMQConfiguration.setBrokerURL(brokerURL);
}
return answer;
diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQConfiguration.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQConfiguration.java
index fe5e46535ab1..c37b68c6e582 100644
--- a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQConfiguration.java
+++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQConfiguration.java
@@ -148,8 +148,8 @@ public class ActiveMQConfiguration extends JmsConfiguration {
if (target instanceof DelegatingConnectionFactory dcf) {
target = dcf.getTargetConnectionFactory();
}
- if (target instanceof ActiveMQConnectionFactory) {
- acf = (ActiveMQConnectionFactory) target;
+ if (target instanceof ActiveMQConnectionFactory activeMQConnectionFactory) {
+ acf = activeMQConnectionFactory;
}
if (acf != null) {
diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/OriginalDestinationPropagateStrategy.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/OriginalDestinationPropagateStrategy.java
index 195fb747bb8d..dfce94678145 100644
--- a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/OriginalDestinationPropagateStrategy.java
+++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/OriginalDestinationPropagateStrategy.java
@@ -40,12 +40,12 @@ public class OriginalDestinationPropagateStrategy implements MessageCreatedStrat
if (exchange.getIn() instanceof JmsMessage) {
JmsMessage msg = exchange.getIn(JmsMessage.class);
Message jms = msg.getJmsMessage();
- if (jms instanceof ActiveMQMessage amq && message instanceof ActiveMQMessage) {
+ if (jms instanceof ActiveMQMessage amq && message instanceof ActiveMQMessage activeMQMessage) {
if (amq.getOriginalDestination() == null) {
ActiveMQDestination from = amq.getDestination();
if (from != null) {
LOG.trace("Setting OriginalDestination: {} on {}", from, message);
- ((ActiveMQMessage) message).setOriginalDestination(from);
+ activeMQMessage.setOriginalDestination(from);
}
}
}
diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/ActiveMQMessageConverter.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/ActiveMQMessageConverter.java
index 4cdbef0bb15d..0ae2d43ef562 100644
--- a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/ActiveMQMessageConverter.java
+++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/ActiveMQMessageConverter.java
@@ -71,13 +71,13 @@ public class ActiveMQMessageConverter {
private static ActiveMQMessage createActiveMQMessage(Exchange exchange) throws JMSException {
Object body = exchange.getIn().getBody();
- if (body instanceof String) {
+ if (body instanceof String str) {
ActiveMQTextMessage answer = new ActiveMQTextMessage();
- answer.setText((String) body);
+ answer.setText(str);
return answer;
- } else if (body instanceof Serializable) {
+ } else if (body instanceof Serializable serializable) {
ActiveMQObjectMessage answer = new ActiveMQObjectMessage();
- answer.setObject((Serializable) body);
+ answer.setObject(serializable);
return answer;
} else {
return new ActiveMQMessage();
(camel) 05/41: (chores): modernize instanceof checks in camel-kafka
Posted by or...@apache.org.
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 613d12b1e37936a53b43d6a25a7334aa53102c2e
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:40:05 2026 +0000
(chores): modernize instanceof checks in camel-kafka
---
.../org/apache/camel/component/kafka/KafkaHeaderDeserializer.java | 4 ++--
.../apache/camel/component/kafka/transform/TimestampRouter.java | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaHeaderDeserializer.java b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaHeaderDeserializer.java
index 645c1883b59f..bbe8eeb32623 100644
--- a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaHeaderDeserializer.java
+++ b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaHeaderDeserializer.java
@@ -74,8 +74,8 @@ public class KafkaHeaderDeserializer implements Processor {
return value;
}
- if (value instanceof byte[]) {
- return new String((byte[]) value, StandardCharsets.UTF_8);
+ if (value instanceof byte[] byteArray) {
+ return new String(byteArray, StandardCharsets.UTF_8);
}
return value.toString();
diff --git a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/transform/TimestampRouter.java b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/transform/TimestampRouter.java
index d0fac8221135..8987568a455d 100644
--- a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/transform/TimestampRouter.java
+++ b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/transform/TimestampRouter.java
@@ -42,10 +42,10 @@ public class TimestampRouter {
Long timestamp = null;
String topicName = ex.getMessage().getHeader("kafka.TOPIC", String.class);
Object rawTimestamp = ex.getMessage().getHeader(timestampHeaderName);
- if (rawTimestamp instanceof Long) {
- timestamp = (Long) rawTimestamp;
- } else if (rawTimestamp instanceof Instant) {
- timestamp = ((Instant) rawTimestamp).toEpochMilli();
+ if (rawTimestamp instanceof Long longValue) {
+ timestamp = longValue;
+ } else if (rawTimestamp instanceof Instant instant) {
+ timestamp = instant.toEpochMilli();
} else if (ObjectHelper.isNotEmpty(rawTimestamp)) {
timestamp = Long.parseLong(rawTimestamp.toString());
}
(camel) 36/41: (chores): modernize instanceof checks in camel-zipfile
Posted by or...@apache.org.
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 3181a8424f41be863ebc5a2a0a86e5f1e977c137
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:49:08 2026 +0000
(chores): modernize instanceof checks in camel-zipfile
---
.../main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
index 5ea553430d23..195829583248 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
@@ -53,8 +53,8 @@ public class ZipIterator implements Iterator<Message>, Closeable {
Objects.requireNonNull(inputStream);
- if (inputStream instanceof ZipArchiveInputStream) {
- zipInputStream = (ZipArchiveInputStream) inputStream;
+ if (inputStream instanceof ZipArchiveInputStream zipArchiveInputStream) {
+ zipInputStream = zipArchiveInputStream;
} else {
try {
ArchiveInputStream input = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.ZIP,
(camel) 38/41: (chores): modernize instanceof checks in camel-xslt
Posted by or...@apache.org.
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 0346116a5a474f229408eb6f62234bb72a8e3c4b
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:51:54 2026 +0000
(chores): modernize instanceof checks in camel-xslt
---
.../org/apache/camel/component/xslt/XmlSourceHandlerFactoryImpl.java | 4 ++--
.../src/main/java/org/apache/camel/component/xslt/XsltBuilder.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XmlSourceHandlerFactoryImpl.java b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XmlSourceHandlerFactoryImpl.java
index 636b9a908d82..59c2ba73d742 100644
--- a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XmlSourceHandlerFactoryImpl.java
+++ b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XmlSourceHandlerFactoryImpl.java
@@ -114,8 +114,8 @@ public class XmlSourceHandlerFactoryImpl implements SourceHandlerFactory {
*/
protected Source getSource(Exchange exchange, Object body) {
// body may already be a source
- if (body instanceof Source) {
- return (Source) body;
+ if (body instanceof Source source) {
+ return source;
}
Source source = null;
if (body != null) {
diff --git a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltBuilder.java b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltBuilder.java
index 41bbf1cefa46..30fc027fde20 100644
--- a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltBuilder.java
+++ b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltBuilder.java
@@ -119,8 +119,8 @@ public class XsltBuilder implements Processor {
source = prepareSource(source);
- if (source instanceof SAXSource) {
- tryAddEntityResolver((SAXSource) source);
+ if (source instanceof SAXSource saxSource) {
+ tryAddEntityResolver(saxSource);
}
LOG.trace("Using {} as source", source);
(camel) 32/41: (chores): modernize instanceof checks in camel-jpa
Posted by or...@apache.org.
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 c7535cddbeaccf8efc4f07df797eb6266388b05f
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:44:56 2026 +0000
(chores): modernize instanceof checks in camel-jpa
---
.../src/main/java/org/apache/camel/component/jpa/JpaProducer.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java
index 64207e95cca8..ad83553046f0 100644
--- a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java
+++ b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java
@@ -211,8 +211,8 @@ public class JpaProducer extends DefaultProducer {
if (params != null) {
params.forEach((key, value) -> {
Object resolvedValue = value;
- if (value instanceof String) {
- resolvedValue = simple.createExpression((String) value).evaluate(exchange, Object.class);
+ if (value instanceof String str) {
+ resolvedValue = simple.createExpression(str).evaluate(exchange, Object.class);
}
query.setParameter(key, resolvedValue);
});
(camel) 17/41: (chores): modernize instanceof checks in camel-webhook
Posted by or...@apache.org.
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 f4523fa413bd2c19ad8f0401ab8858c478d16a85
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:04:59 2026 +0000
(chores): modernize instanceof checks in camel-webhook
---
.../camel/component/webhook/WebhookRoutePolicy.java | 3 +--
.../org/apache/camel/component/webhook/WebhookUtils.java | 16 ++++++++--------
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookRoutePolicy.java b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookRoutePolicy.java
index 1e489365feb9..696a7d4b9877 100644
--- a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookRoutePolicy.java
+++ b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookRoutePolicy.java
@@ -35,8 +35,7 @@ class WebhookRoutePolicy extends RoutePolicySupport {
super.onInit(route);
route.setAutoStartup(false);
- if (route.getEndpoint() instanceof WebhookEndpoint) {
- WebhookEndpoint webhook = (WebhookEndpoint) route.getEndpoint();
+ if (route.getEndpoint() instanceof WebhookEndpoint webhook) {
if (webhook.getConfiguration() != null && webhook.getConfiguration().isWebhookAutoRegister()) {
throw new IllegalStateException(
"Webhook auto-register is enabled on endpoint " + webhook
diff --git a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookUtils.java b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookUtils.java
index ec4701d5d910..ad30b424e8a0 100644
--- a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookUtils.java
+++ b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookUtils.java
@@ -41,12 +41,12 @@ public final class WebhookUtils {
RestConsumerFactory factory = null;
if (configuration.getWebhookComponentName() != null) {
Object comp = context.getRegistry().lookupByName(configuration.getWebhookComponentName());
- if (comp instanceof RestConsumerFactory) {
- factory = (RestConsumerFactory) comp;
+ if (comp instanceof RestConsumerFactory restconsumerfactory4) {
+ factory = restconsumerfactory4;
} else {
comp = context.getComponent(configuration.getWebhookComponentName());
- if (comp instanceof RestConsumerFactory) {
- factory = (RestConsumerFactory) comp;
+ if (comp instanceof RestConsumerFactory restconsumerfactory3) {
+ factory = restconsumerfactory3;
}
}
@@ -64,8 +64,8 @@ public final class WebhookUtils {
if (factory == null) {
for (String name : context.getComponentNames()) {
Component comp = context.getComponent(name);
- if (comp instanceof RestConsumerFactory) {
- factory = (RestConsumerFactory) comp;
+ if (comp instanceof RestConsumerFactory restconsumerfactory2) {
+ factory = restconsumerfactory2;
break;
}
}
@@ -85,9 +85,9 @@ public final class WebhookUtils {
RestConsumerFactory found = null;
for (String name : DEFAULT_REST_CONSUMER_COMPONENTS) {
Object comp = context.getComponent(name, true);
- if (comp instanceof RestConsumerFactory) {
+ if (comp instanceof RestConsumerFactory restconsumerfactory) {
if (found == null) {
- found = (RestConsumerFactory) comp;
+ found = restconsumerfactory;
} else {
throw new IllegalArgumentException(
"Multiple RestConsumerFactory found on classpath. Configure explicit which component to use");
(camel) 34/41: (chores): modernize instanceof checks in camel-mustache
Posted by or...@apache.org.
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 5239836a877b4db206987b80e05d414e1b57b31a
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:46:56 2026 +0000
(chores): modernize instanceof checks in camel-mustache
---
.../java/org/apache/camel/component/mustache/MustacheEndpoint.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java b/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java
index 9debf7fca3f2..83d351081f43 100644
--- a/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java
+++ b/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java
@@ -139,8 +139,8 @@ public class MustacheEndpoint extends ResourceEndpoint {
Thread.currentThread().setContextClassLoader(apcl);
}
Mustache newMustache;
- if (startDelimiter != null && endDelimiter != null && mustacheFactory instanceof DefaultMustacheFactory) {
- DefaultMustacheFactory defaultMustacheFactory = (DefaultMustacheFactory) mustacheFactory;
+ if (startDelimiter != null && endDelimiter != null
+ && mustacheFactory instanceof DefaultMustacheFactory defaultMustacheFactory) {
newMustache = defaultMustacheFactory.compile(resourceReader, resourceUri, startDelimiter, endDelimiter);
} else {
newMustache = mustacheFactory.compile(resourceReader, resourceUri);
(camel) 31/41: (chores): modernize instanceof checks in camel-nats
Posted by or...@apache.org.
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 067d1c1c272ae8163c097ff20c3c6a5b1f6ec0ed
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:43:05 2026 +0000
(chores): modernize instanceof checks in camel-nats
---
.../src/main/java/org/apache/camel/component/nats/NatsProducer.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsProducer.java b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsProducer.java
index 3fc92ceef7c6..3c308a7035be 100644
--- a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsProducer.java
+++ b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsProducer.java
@@ -135,8 +135,8 @@ public class NatsProducer extends DefaultAsyncProducer {
exchange.getIn().getHeaders().forEach((key, value) -> {
if (!filteringStrategy.applyFilterToCamelHeaders(key, value, exchange)) {
String headerValue;
- if (value instanceof byte[]) {
- headerValue = new String((byte[]) value, StandardCharsets.UTF_8);
+ if (value instanceof byte[] byteArray) {
+ headerValue = new String(byteArray, StandardCharsets.UTF_8);
} else {
headerValue = String.valueOf(value);
}
(camel) 15/41: (chores): modernize instanceof checks in camel-util
Posted by or...@apache.org.
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 d381c6f0fb31875af41f36a122e6087fa4a08d43
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:51:08 2026 +0000
(chores): modernize instanceof checks in camel-util
---
core/camel-util/src/main/java/org/apache/camel/util/ObjectHelper.java | 4 ++--
.../java/org/apache/camel/util/concurrent/RejectableFutureTask.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/core/camel-util/src/main/java/org/apache/camel/util/ObjectHelper.java b/core/camel-util/src/main/java/org/apache/camel/util/ObjectHelper.java
index 2afcdbd3f59b..9316bdf8ae86 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/ObjectHelper.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/ObjectHelper.java
@@ -1320,8 +1320,8 @@ public final class ObjectHelper {
* @return <tt>true</tt> if its a {@link Float#NaN} or {@link Double#NaN}.
*/
public static boolean isNaN(Object value) {
- return value instanceof Float && ((Float) value).isNaN()
- || value instanceof Double && ((Double) value).isNaN();
+ return value instanceof Float floatValue && floatValue.isNaN()
+ || value instanceof Double doubleValue && doubleValue.isNaN();
}
/**
diff --git a/core/camel-util/src/main/java/org/apache/camel/util/concurrent/RejectableFutureTask.java b/core/camel-util/src/main/java/org/apache/camel/util/concurrent/RejectableFutureTask.java
index ba83d05951e0..6ff20e8cd83a 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/concurrent/RejectableFutureTask.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/concurrent/RejectableFutureTask.java
@@ -30,12 +30,12 @@ public class RejectableFutureTask<V> extends FutureTask<V> implements Rejectable
public RejectableFutureTask(Callable<V> callable) {
super(callable);
- this.rejectable = callable instanceof Rejectable ? (Rejectable) callable : null;
+ this.rejectable = callable instanceof Rejectable rejectable2 ? rejectable2 : null;
}
public RejectableFutureTask(Runnable runnable, V result) {
super(runnable, result);
- this.rejectable = runnable instanceof Rejectable ? (Rejectable) runnable : null;
+ this.rejectable = runnable instanceof Rejectable rejectable2 ? rejectable2 : null;
}
@Override
(camel) 18/41: (chores): modernize instanceof checks in camel-platform-http-vertx
Posted by or...@apache.org.
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 b0588f310e9335ce13937c1bca295201979139fa
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:06:23 2026 +0000
(chores): modernize instanceof checks in camel-platform-http-vertx
---
.../http/vertx/VertxPlatformHttpSupport.java | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java
index c0683453834a..3c9eba48653b 100644
--- a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java
+++ b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java
@@ -162,10 +162,10 @@ public final class VertxPlatformHttpSupport {
}
static Integer determineContentLength(Object body) {
- if (body instanceof byte[]) {
- return ((byte[]) body).length;
- } else if (body instanceof ByteBuffer) {
- return ((ByteBuffer) body).remaining();
+ if (body instanceof byte[] byteArray) {
+ return byteArray.length;
+ } else if (body instanceof ByteBuffer bytebuffer) {
+ return bytebuffer.remaining();
}
return null;
}
@@ -186,13 +186,13 @@ public final class VertxPlatformHttpSupport {
LOGGER.trace("No payload to send as reply for exchange: {}", camelExchange);
ctx.end();
promise.complete();
- } else if (body instanceof String) {
- ctx.end((String) body);
+ } else if (body instanceof String string) {
+ ctx.end(string);
promise.complete();
- } else if (body instanceof InputStream) {
- writeResponseAs(promise, ctx, (InputStream) body);
- } else if (body instanceof Buffer) {
- ctx.end((Buffer) body);
+ } else if (body instanceof InputStream inputstream) {
+ writeResponseAs(promise, ctx, inputstream);
+ } else if (body instanceof Buffer buffer) {
+ ctx.end(buffer);
promise.complete();
} else if (body instanceof ByteBuffer bb) {
writeResponseAs(promise, ctx, bb);
(camel) 12/41: (chores): modernize instanceof checks in camel-kubernetes
Posted by or...@apache.org.
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 add8bb27898163f0edfbd0a4d749e85aa283254e
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:47:22 2026 +0000
(chores): modernize instanceof checks in camel-kubernetes
---
.../component/kubernetes/config_maps/vault/ConfigmapsDevConsole.java | 4 ++--
.../kubernetes/config_maps/vault/ConfigmapsReloadTriggerTask.java | 4 ++--
.../camel/component/kubernetes/secrets/vault/SecretsDevConsole.java | 4 ++--
.../component/kubernetes/secrets/vault/SecretsReloadTriggerTask.java | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/vault/ConfigmapsDevConsole.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/vault/ConfigmapsDevConsole.java
index c4a573660d5a..3cf77ff07474 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/vault/ConfigmapsDevConsole.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/vault/ConfigmapsDevConsole.java
@@ -51,8 +51,8 @@ public class ConfigmapsDevConsole extends AbstractDevConsole {
if (getCamelContext().getPropertiesComponent().hasPropertiesFunction("configmap")) {
PropertiesFunction pf = getCamelContext().getPropertiesComponent().getPropertiesFunction("configmap");
- if (pf instanceof ConfigMapPropertiesFunction) {
- propertiesFunction = (ConfigMapPropertiesFunction) pf;
+ if (pf instanceof ConfigMapPropertiesFunction configmappropertiesfunction) {
+ propertiesFunction = configmappropertiesfunction;
}
}
KubernetesConfigMapVaultConfiguration kubernetes
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/vault/ConfigmapsReloadTriggerTask.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/vault/ConfigmapsReloadTriggerTask.java
index 3fd7a0f11058..53c88cc96c9a 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/vault/ConfigmapsReloadTriggerTask.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/vault/ConfigmapsReloadTriggerTask.java
@@ -89,8 +89,8 @@ public class ConfigmapsReloadTriggerTask extends ServiceSupport implements Camel
// auto-detect secrets in-use
PropertiesComponent pc = camelContext.getPropertiesComponent();
PropertiesFunction pf = pc.getPropertiesFunction("configmap");
- if (pf instanceof ConfigMapPropertiesFunction) {
- propertiesFunction = (ConfigMapPropertiesFunction) pf;
+ if (pf instanceof ConfigMapPropertiesFunction configmappropertiesfunction) {
+ propertiesFunction = configmappropertiesfunction;
LOG.info("Auto-detecting configmaps from properties-function: {}", pf.getName());
}
// specific secrets
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/secrets/vault/SecretsDevConsole.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/secrets/vault/SecretsDevConsole.java
index 3b7d32d9a613..c95e05f96d74 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/secrets/vault/SecretsDevConsole.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/secrets/vault/SecretsDevConsole.java
@@ -50,8 +50,8 @@ public class SecretsDevConsole extends AbstractDevConsole {
if (getCamelContext().getPropertiesComponent().hasPropertiesFunction("secret")) {
PropertiesFunction pf = getCamelContext().getPropertiesComponent().getPropertiesFunction("secret");
- if (pf instanceof SecretPropertiesFunction) {
- propertiesFunction = (SecretPropertiesFunction) pf;
+ if (pf instanceof SecretPropertiesFunction secretpropertiesfunction) {
+ propertiesFunction = secretpropertiesfunction;
}
}
KubernetesVaultConfiguration kubernetes = getCamelContext().getVaultConfiguration().getKubernetesVaultConfiguration();
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/secrets/vault/SecretsReloadTriggerTask.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/secrets/vault/SecretsReloadTriggerTask.java
index 316539975b07..08db0f9fa210 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/secrets/vault/SecretsReloadTriggerTask.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/secrets/vault/SecretsReloadTriggerTask.java
@@ -86,8 +86,8 @@ public class SecretsReloadTriggerTask extends ServiceSupport implements CamelCon
// auto-detect secrets in-use
PropertiesComponent pc = camelContext.getPropertiesComponent();
PropertiesFunction pf = pc.getPropertiesFunction("secret");
- if (pf instanceof SecretPropertiesFunction) {
- propertiesFunction = (SecretPropertiesFunction) pf;
+ if (pf instanceof SecretPropertiesFunction secretpropertiesfunction) {
+ propertiesFunction = secretpropertiesfunction;
LOG.debug("Auto-detecting secrets from properties-function: {}", pf.getName());
}
// specific secrets
(camel) 37/41: (chores): modernize instanceof checks in camel-attachments
Posted by or...@apache.org.
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 061d5ce6290b60fdec9f88b3c55491fec1b1acbc
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 11:50:26 2026 +0000
(chores): modernize instanceof checks in camel-attachments
---
.../java/org/apache/camel/attachment/DefaultAttachment.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/components/camel-attachments/src/main/java/org/apache/camel/attachment/DefaultAttachment.java b/components/camel-attachments/src/main/java/org/apache/camel/attachment/DefaultAttachment.java
index b95d694e6aff..88e68aa2be62 100644
--- a/components/camel-attachments/src/main/java/org/apache/camel/attachment/DefaultAttachment.java
+++ b/components/camel-attachments/src/main/java/org/apache/camel/attachment/DefaultAttachment.java
@@ -49,8 +49,8 @@ public class DefaultAttachment implements Attachment {
public String getHeader(String name) {
if (headers != null) {
Object headerObject = headers.get(name);
- if (headerObject instanceof String) {
- return (String) headerObject;
+ if (headerObject instanceof String str) {
+ return str;
} else if (headerObject instanceof Collection<?>) {
return CollectionHelper.collectionAsCommaDelimitedString((Collection<?>) headerObject);
}
@@ -65,8 +65,8 @@ public class DefaultAttachment implements Attachment {
Object headerObject = headers.get(name);
if (headerObject instanceof List<?>) {
return (List<String>) headerObject;
- } else if (headerObject instanceof String) {
- return Collections.singletonList((String) headerObject);
+ } else if (headerObject instanceof String str) {
+ return Collections.singletonList(str);
}
}
return null;
@@ -113,8 +113,8 @@ public class DefaultAttachment implements Attachment {
@Override
public boolean equals(Object other) {
- if (other instanceof Attachment) {
- DataHandler otherDh = ((Attachment) other).getDataHandler();
+ if (other instanceof Attachment attachment) {
+ DataHandler otherDh = attachment.getDataHandler();
return dataHandler.equals(otherDh);
}
return false;
(camel) 13/41: (chores): modernize instanceof checks in camel-console
Posted by or...@apache.org.
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 c738926521a58fe4fcecf0fe441377de7697a83e
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jan 26 10:48:07 2026 +0000
(chores): modernize instanceof checks in camel-console
---
.../java/org/apache/camel/impl/console/PropertiesDevConsole.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/core/camel-console/src/main/java/org/apache/camel/impl/console/PropertiesDevConsole.java b/core/camel-console/src/main/java/org/apache/camel/impl/console/PropertiesDevConsole.java
index 2ebe943ee558..5f1c07fadd3f 100644
--- a/core/camel-console/src/main/java/org/apache/camel/impl/console/PropertiesDevConsole.java
+++ b/core/camel-console/src/main/java/org/apache/camel/impl/console/PropertiesDevConsole.java
@@ -47,8 +47,8 @@ public class PropertiesDevConsole extends AbstractDevConsole {
Properties p = pc.loadProperties();
OrderedLocationProperties olp = null;
- if (p instanceof OrderedLocationProperties) {
- olp = (OrderedLocationProperties) p;
+ if (p instanceof OrderedLocationProperties orderedlocationproperties2) {
+ olp = orderedlocationproperties2;
}
for (var entry : p.entrySet()) {
String k = entry.getKey().toString();
@@ -75,8 +75,8 @@ public class PropertiesDevConsole extends AbstractDevConsole {
JsonArray arr = new JsonArray();
Properties p = pc.loadProperties();
OrderedLocationProperties olp = null;
- if (p instanceof OrderedLocationProperties) {
- olp = (OrderedLocationProperties) p;
+ if (p instanceof OrderedLocationProperties orderedlocationproperties) {
+ olp = orderedlocationproperties;
}
for (var entry : p.entrySet()) {
String k = entry.getKey().toString();