BartMiki commented on code in PR #12915:
URL: https://github.com/apache/druid/pull/12915#discussion_r952298950


##########
extensions-contrib/kafka-emitter/src/main/java/org/apache/druid/emitter/kafka/KafkaEmitter.java:
##########
@@ -166,14 +169,14 @@ private void sendToKafka(final String topic, 
MemoryBoundLinkedBlockingQueue<Stri
   public void emit(final Event event)
   {
     if (event != null) {
-      ImmutableMap.Builder<String, Object> resultBuilder = 
ImmutableMap.<String, Object>builder().putAll(event.toMap());
-      if (config.getClusterName() != null) {
-        resultBuilder.put("clusterName", config.getClusterName());
-      }
-      Map<String, Object> result = resultBuilder.build();
-
       try {
-        String resultJson = jsonMapper.writeValueAsString(result);
+        EventMap map = event.toMap();
+        if (config.getClusterName() != null) {
+          map.put("clusterName", config.getClusterName());

Review Comment:
   Extending ImmutableMap is tricky (and IMO not worth it). I just added this:
   ```java
     /**
      * Convert this EventMap to a builder. Performs copy of the whole EventMap.
      */
     public Builder asBuilder() {return new Builder().putAll(this);}
   ```
   So you can get a builder out of the existing EventMap and modify the copy. 



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to