You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Andrea Cosentino (Jira)" <ji...@apache.org> on 2026/08/04 12:27:00 UTC
[jira] [Resolved] (CAMEL-24262) camel-aws2: producer catch blocks eagerly dereference nullable awsErrorDetails() when logging the error code
[ https://issues.apache.org/jira/browse/CAMEL-24262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrea Cosentino resolved CAMEL-24262.
--------------------------------------
Resolution: Fixed
Fixed on main via PR https://github.com/apache/camel/pull/25324 — AWS producer catch blocks now go through AwsExceptionUtil, which guards the nullable awsErrorDetails() before dereferencing it, across the aws components. Main-only (4.22.0); the acute health-check NPE was already backported to 4.18.4/4.14.9 via CAMEL-24251.
_Claude Code on behalf of Andrea Cosentino (@oscerd)._
> camel-aws2: producer catch blocks eagerly dereference nullable awsErrorDetails() when logging the error code
> ------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24262
> URL: https://issues.apache.org/jira/browse/CAMEL-24262
> Project: Camel
> Issue Type: Bug
> Components: camel-aws
> Reporter: Andrea Cosentino
> Assignee: Andrea Cosentino
> Priority: Major
> Fix For: 4.22.0
>
>
> h3. Summary
> Related to CAMEL-24251 (same root cause, different location). Across 28 AWS v2 producers, the {{catch (AwsServiceException ase)}} blocks log the error code with:
> {code:java}
> } catch (AwsServiceException ase) {
> LOG.trace("List Brokers command returned the error code {}", ase.awsErrorDetails().errorCode());
> throw ase;
> }
> {code}
> {{AwsServiceException.awsErrorDetails()}} is nullable (see CAMEL-24251, where the same dereference is reproduced throwing NPE in the producer health checks). Here the dereference sits on the *main error-handling path*: if {{awsErrorDetails()}} is null, {{ase.awsErrorDetails().errorCode()}} throws {{NullPointerException}} and the original {{AwsServiceException}} is *masked* by that NPE at the {{throw}} site.
> Because the expression is a method argument, Java evaluates it *eagerly* — so this happens even when TRACE logging is disabled. It is not gated by the log level.
> h3. Scope
> 358 such log sites across 28 producer files (every operation's catch block). For a genuine AWS service error the SDK populates {{awsErrorDetails}}, so the practical trigger is narrow (synthetic / edge-case exceptions, as in CAMEL-24251) — this is *lower severity* than CAMEL-24251, filed for consistency and defense-in-depth rather than a frequently-hit crash.
> h3. Proposed fix (low-churn)
> Add a null-safe helper in {{camel-aws-common}}, e.g.:
> {code:java}
> public static String errorCode(AwsServiceException e) {
> return e.awsErrorDetails() != null ? e.awsErrorDetails().errorCode() : null;
> }
> {code}
> and migrate the log sites to {{AwsExceptionHelper.errorCode(ase)}} opportunistically (e.g. per component, alongside other work), rather than one 358-site sweep. This also removes the eager-deref foot-gun for future producers.
> Raised from an automated audit of the camel-aws components.
> ----
> _Reported by Claude Code on behalf of acosentino._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)