Skip to content

Commit

Permalink
Enhance application-x-struct data type
Browse files Browse the repository at this point in the history
- Support empty message body value and initialize the application-x-struct data type with empty JsonNode {} value
- Allows follow-up action Kamelets such as insert-field-action to add more fields to the empty JsonNode body
  • Loading branch information
christophd committed Sep 18, 2023
1 parent a0102c0 commit bb84c2f
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

import com.fasterxml.jackson.databind.JsonNode;
import org.apache.camel.CamelExecutionException;
Expand Down Expand Up @@ -50,6 +51,10 @@ public void transform(Message message, DataType fromType, DataType toType) {
}

private InputStream getBodyAsStream(Message message) throws InvalidPayloadException {
if (message.getBody() == null) {
return new ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8));
}

InputStream bodyStream = message.getBody(InputStream.class);

if (bodyStream == null) {
Expand Down

0 comments on commit bb84c2f

Please sign in to comment.