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/24 08:29:00 UTC

[jira] [Commented] (CAMEL-24350) camel-google-pubsub: producer NPEs on non-convertible headers and drops non-Exchange list elements

    [ https://issues.apache.org/jira/browse/CAMEL-24350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18107267#comment-18107267 ] 

Andrea Cosentino commented on CAMEL-24350:
------------------------------------------

Backported to the maintenance branches: camel-4.22.x https://github.com/apache/camel/pull/25618, camel-4.18.x https://github.com/apache/camel/pull/25619, camel-4.14.x https://github.com/apache/camel/pull/25620. fixVersions will be extended to 4.22.1/4.18.5/4.14.10 once they merge.

> camel-google-pubsub: producer NPEs on non-convertible headers and drops non-Exchange list elements
> --------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24350
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24350
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-google-pubsub
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Minor
>             Fix For: 4.23.0
>
>
> 1. Header pass-through can hand protobuf a null value:
> {code:java}
> // GooglePubsubProducer.java:126-133
> for (String camelHeader : exchange.getIn().getHeaders().keySet()) {
>     String value = exchange.getIn().getHeader(camelHeader, String.class);
>     if (headerFilterStrategy != null && headerFilterStrategy.applyFilterToCamelHeaders(camelHeader, value, exchange)) {
>         continue;
>     }
>     messageBuilder.putAttributes(camelHeader, value);
> }
> {code}
> {{putAttributes}} rejects null, so a header whose value is null or does not convert to String aborts the send with an NPE. The filter strategy is also consulted with a null value.
> 2. A List body that mixes exchanges and plain payloads silently drops the plain ones:
> {code:java}
> // GooglePubsubProducer.java:72-82
> if (exchange.getIn().getBody() instanceof List) {
>     boolean groupedExchanges = false;
>     for (Object body : exchange.getIn().getBody(List.class)) {
>         if (body instanceof Exchange) { send((Exchange) body); groupedExchanges = true; }
>     }
>     if (!groupedExchanges) { send(exchange); }
> }
> {code}
> Non-Exchange elements are never published when at least one element is an Exchange. The same shape exists in {{consumer/AcknowledgeSync:72-76}}.
> Found during a source audit of the {{components/camel-google}} module family against main @ c3b01310be15.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)