rohangarg commented on code in PR #12915:
URL: https://github.com/apache/druid/pull/12915#discussion_r952217858
##########
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:
If that works, I think that'll be ok. But I'm not sure if it will expose all
methods which `HashMap` does. Maybe, can also return an `ImmutableMap` object
from the builder's build. Immutability would also require making the default
constructor private so that we don't create a mutable map from there.
--
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]