This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch objectHelper in repository https://gitbox.apache.org/repos/asf/camel.git
commit aadcc2ebc8937a3143e848763f31456a2c8814cb Author: Andrea Cosentino <[email protected]> AuthorDate: Wed Jan 28 08:19:52 2026 +0100 Camel-AWS components: Use ObjectHelper for null checks Signed-off-by: Andrea Cosentino <[email protected]> --- .../apache/camel/component/aws2/athena/Athena2Component.java | 3 ++- .../apache/camel/component/aws2/athena/Athena2Endpoint.java | 6 +++--- .../apache/camel/component/aws2/athena/Athena2Producer.java | 10 +++++----- .../apache/camel/component/aws2/athena/Athena2QueryHelper.java | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java index e502642a8300..3ded9634a330 100644 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java +++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java @@ -23,6 +23,7 @@ import org.apache.camel.Endpoint; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.annotations.Component; import org.apache.camel.support.HealthCheckComponent; +import org.apache.camel.util.ObjectHelper; /** * For working with Amazon Athena SDK v2. @@ -44,7 +45,7 @@ public class Athena2Component extends HealthCheckComponent { @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { Athena2Configuration configurationClone - = this.configuration != null ? this.configuration.copy() : new Athena2Configuration(); + = ObjectHelper.isNotEmpty(this.configuration) ? this.configuration.copy() : new Athena2Configuration(); Athena2Endpoint endpoint = new Athena2Endpoint(uri, this, configurationClone); setProperties(endpoint, parameters); if (Boolean.FALSE.equals(configurationClone.isUseDefaultCredentialsProvider()) diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java index 9b098e3316cb..86e00791af64 100644 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java +++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java @@ -67,7 +67,7 @@ public class Athena2Endpoint extends DefaultEndpoint implements EndpointServiceL public void doInit() throws Exception { super.doInit(); - athenaClient = configuration.getAmazonAthenaClient() != null + athenaClient = ObjectHelper.isNotEmpty(configuration.getAmazonAthenaClient()) ? configuration.getAmazonAthenaClient() : Athena2ClientFactory.getAthenaClient(configuration); @@ -76,7 +76,7 @@ public class Athena2Endpoint extends DefaultEndpoint implements EndpointServiceL @Override public void doStop() throws Exception { if (ObjectHelper.isEmpty(configuration.getAmazonAthenaClient())) { - if (athenaClient != null) { + if (ObjectHelper.isNotEmpty(athenaClient)) { athenaClient.close(); } } @@ -114,7 +114,7 @@ public class Athena2Endpoint extends DefaultEndpoint implements EndpointServiceL @Override public Map<String, String> getServiceMetadata() { - if (configuration.getDatabase() != null) { + if (ObjectHelper.isNotEmpty(configuration.getDatabase())) { return Map.of("database", configuration.getDatabase()); } return null; diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Producer.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Producer.java index c87d2a602ba1..7a7372fb9f89 100644 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Producer.java +++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Producer.java @@ -133,7 +133,7 @@ public class Athena2Producer extends DefaultProducer { GetQueryResultsRequest request = doGetQueryResultsRequest(queryExecutionId, exchange).build(); GetQueryResultsResponse response = athenaClient.getQueryResults(request); message.setHeader(Athena2Constants.NEXT_TOKEN, response.nextToken()); - message.setHeader(Athena2Constants.IS_TRUNCATED, response.nextToken() != null); + message.setHeader(Athena2Constants.IS_TRUNCATED, ObjectHelper.isNotEmpty(response.nextToken())); message.setBody(response); } else if (outputType == Athena2OutputType.S3Pointer) { GetQueryExecutionResponse response = doGetQueryExecution(queryExecutionId, athenaClient); @@ -190,7 +190,7 @@ public class Athena2Producer extends DefaultProducer { ListQueryExecutionsResponse response = athenaClient.listQueryExecutions(request.build()); Message message = getMessageForResponse(exchange); message.setHeader(Athena2Constants.NEXT_TOKEN, response.nextToken()); - message.setHeader(Athena2Constants.IS_TRUNCATED, response.nextToken() != null); + message.setHeader(Athena2Constants.IS_TRUNCATED, ObjectHelper.isNotEmpty(response.nextToken())); message.setBody(response); } @@ -306,7 +306,7 @@ public class Athena2Producer extends DefaultProducer { Boolean.class, () -> getConfiguration().isIncludeTrace(), "include trace"); - return includeTrace != null ? includeTrace : false; + return ObjectHelper.isNotEmpty(includeTrace) ? includeTrace : false; } private String determineNextToken(final Exchange exchange) { @@ -469,7 +469,7 @@ public class Athena2Producer extends DefaultProducer { "producers", WritableHealthCheckRepository.class); - if (healthCheckRepository != null) { + if (ObjectHelper.isNotEmpty(healthCheckRepository)) { String id = getEndpoint().getId(); producerHealthCheck = new Athena2ProducerHealthCheck(getEndpoint(), id); producerHealthCheck.setEnabled(getEndpoint().getComponent().isHealthCheckProducerEnabled()); @@ -479,7 +479,7 @@ public class Athena2Producer extends DefaultProducer { @Override protected void doStop() throws Exception { - if (healthCheckRepository != null && producerHealthCheck != null) { + if (ObjectHelper.isNotEmpty(healthCheckRepository) && ObjectHelper.isNotEmpty(producerHealthCheck)) { healthCheckRepository.removeHealthCheck(producerHealthCheck); producerHealthCheck = null; } diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2QueryHelper.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2QueryHelper.java index 97fe349a05d0..6883807b9866 100644 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2QueryHelper.java +++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2QueryHelper.java @@ -232,7 +232,7 @@ class Athena2QueryHelper { } // Generic errors happen sometimes in Athena. It's possible that a retry will fix the problem. - if (stateChangeReason != null && stateChangeReason.contains("GENERIC_INTERNAL_ERROR") + if (ObjectHelper.isNotEmpty(stateChangeReason) && stateChangeReason.contains("GENERIC_INTERNAL_ERROR") && (this.retry.contains("generic") || this.retry.contains("retryable"))) { LOG.trace("AWS Athena start query execution detected generic error ({}), marked as retryable", stateChangeReason); @@ -240,7 +240,7 @@ class Athena2QueryHelper { } // Resource exhaustion happens sometimes in Athena. It's possible that a retry will fix the problem. - if (stateChangeReason != null && stateChangeReason.contains("exhausted resources at this scale factor") + if (ObjectHelper.isNotEmpty(stateChangeReason) && stateChangeReason.contains("exhausted resources at this scale factor") && (this.retry.contains("exhausted") || this.retry.contains("retryable"))) { LOG.trace("AWS Athena start query execution detected resource exhaustion error ({}), marked as retryable", stateChangeReason);
