diff --git a/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/metric/JacksonMetric.java b/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/metric/JacksonMetric.java index d14f234e88..87aa699a32 100644 --- a/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/metric/JacksonMetric.java +++ b/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/metric/JacksonMetric.java @@ -132,20 +132,22 @@ public Integer getFlags() { */ public abstract static class Builder> extends JacksonEvent.Builder { - //protected final Map data; - //protected EventHandle eventHandle; + private final Map mdata; public Builder() { - data = new HashMap(); + if (data == null) { + data = new HashMap(); + } + mdata = (HashMap)data; eventHandle = null; } public void put(String key, Object value) { - ((HashMap)data).put(key, value); + mdata.put(key, value); } public void computeIfAbsent(String key, Function f) { - ((HashMap)data).computeIfAbsent(key, f); + mdata.computeIfAbsent(key, f); } /** diff --git a/data-prepper-core/src/test/java/org/opensearch/dataprepper/core/peerforwarder/codec/PeerForwarderCodecAppConfig_SerializationFilterIT.java b/data-prepper-core/src/test/java/org/opensearch/dataprepper/core/peerforwarder/codec/PeerForwarderCodecAppConfig_SerializationFilterIT.java index 71a59ca32f..9ef9fe5f61 100644 --- a/data-prepper-core/src/test/java/org/opensearch/dataprepper/core/peerforwarder/codec/PeerForwarderCodecAppConfig_SerializationFilterIT.java +++ b/data-prepper-core/src/test/java/org/opensearch/dataprepper/core/peerforwarder/codec/PeerForwarderCodecAppConfig_SerializationFilterIT.java @@ -196,7 +196,6 @@ void filter_will_deserialize_known_classes_which_are_nested_inside_other_objects void filter_will_deserialize_known_Event_classes(final JacksonEvent.Builder jacksonEventBuilder) throws IOException, ClassNotFoundException { final Event event = jacksonEventBuilder .withEventType(UUID.randomUUID().toString()) - .withData(Collections.singletonMap(UUID.randomUUID().toString(), UUID.randomUUID().toString())) .build(); final PeerForwardingEvents peerForwardingEvents = new PeerForwardingEvents(Collections.singletonList(event), UUID.randomUUID().toString(), UUID.randomUUID().toString()); final byte[] serializedBytes = createByteArrayWithObject(peerForwardingEvents); @@ -267,7 +266,6 @@ void all_subclasses_of_Event_are_verified_in_this_test_suite_to_be_acceptable_fo .filter(b -> b instanceof JacksonEvent.Builder) .map(b -> (JacksonEvent.Builder) b) .map(b -> b.withEventType(UUID.randomUUID().toString())) - .map(b -> b.withData(Collections.singletonMap(UUID.randomUUID().toString(), UUID.randomUUID().toString()))) .map(b -> b.build()) .map(e -> e.getClass()) .collect(Collectors.toSet()); @@ -596,4 +594,4 @@ public Stream provideArguments(final ExtensionContext conte ); } } -} \ No newline at end of file +}