You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/02/23 16:27:31 UTC
[GitHub] [camel-kafka-connector] rk3rn3r commented on a change in pull request #1052: Convert Struct to Map
rk3rn3r commented on a change in pull request #1052:
URL: https://github.com/apache/camel-kafka-connector/pull/1052#discussion_r581187230
##########
File path: core/src/main/java/org/apache/camel/kafkaconnector/CamelSinkTask.java
##########
@@ -225,15 +230,47 @@ If the CamelMainSupport instance fails to be instantiated (ie.: due to missing c
}
}
- private static void mapHeader(Header header, String prefix, Map<String, Object> destination) {
+ private void mapHeader(Header header, String prefix, Map<String, Object> destination) {
final String key = StringHelper.after(header.key(), prefix, header.key());
final Schema schema = header.schema();
if (schema.type().equals(Schema.BYTES_SCHEMA.type()) && Objects.equals(schema.name(), Decimal.LOGICAL_NAME)) {
destination.put(key, Decimal.toLogical(schema, (byte[]) header.value()));
} else {
- destination.put(key, header.value());
+ destination.put(key, convertValueFromStruct(header.schema(), header.value()));
+ }
+ }
+
+ private Object convertValueFromStruct(Schema schema, Object value) {
Review comment:
This also converts message keys, so another name like "convertStructToMap()" makes more sense.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org