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

Claus Ibsen commented on CAMEL-26172:
-------------------------------------

PR: https://github.com/apache/camel/pull/28998

The JSON is now written before the request is sent, so a payload Jackson cannot 
write fails without sending anything. A byte array, stream, Reader, File, Path, 
the file consumer's file and a ByteBuffer body are converted to text in the 
event. Upgrade guide entry added, since bytes were sent as base64 before.

_Claude Code on behalf of Claus Ibsen (davsclaus)_

> camel-splunk-hec - a stream body sends a truncated invalid JSON request, and 
> bytes are sent as base64 and a File as its path
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26172
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26172
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-splunk-hec
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Found while adding the catalog body types of splunk-hec (CAMEL-24961, PR 
> #28412).
> h4. 1. A stream body sends a truncated, invalid JSON request to Splunk
> {{SplunkHECProducer.process}} (main 2a465aa4814c, lines 105-106) writes the 
> payload with Jackson inside an {{EntityTemplate}}, that is while the request 
> is already being sent. With an {{InputStream}} body Jackson fails half way, 
> the exchange fails, but a truncated, invalid JSON request has already reached 
> the server. Checked on 4.24.0-SNAPSHOT with a local HTTP server as the HEC 
> endpoint.
> Proposed: serialize the payload to a byte array before sending, so a 
> serialization failure happens before any request is made (and convert stream 
> bodies to text, see 2).
> h4. 2. A byte array is sent as base64 and a File as its path
> {{SplunkHECProducer.createPayload}} (main 2a465aa4814c, line 134) puts 
> {{message.getBody()}} as is in the event, so Jackson writes a {{byte[]}} body 
> as a base64 string and a {{java.io.File}} as its path, with no error. Checked 
> on 4.24.0-SNAPSHOT with the local HTTP server.
> Proposed: convert byte array, stream and file bodies to text before putting 
> them in the event.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to