From 7168e30fa6746ab1e460418bd07320450491e0f6 Mon Sep 17 00:00:00 2001 From: Randall Hauch Date: Wed, 9 Sep 2015 10:13:04 -0500 Subject: [PATCH] Corrected order that MeteredKeyValueStore initialized its member fields so that the context is set before it is needed. This prevents a NullPointerException when running with a key value store. --- .../kafka/streaming/state/MeteredKeyValueStore.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/stream/src/main/java/org/apache/kafka/streaming/state/MeteredKeyValueStore.java b/stream/src/main/java/org/apache/kafka/streaming/state/MeteredKeyValueStore.java index 805de51c8acab..08d582702d9e5 100644 --- a/stream/src/main/java/org/apache/kafka/streaming/state/MeteredKeyValueStore.java +++ b/stream/src/main/java/org/apache/kafka/streaming/state/MeteredKeyValueStore.java @@ -66,6 +66,11 @@ public MeteredKeyValueStore(final String name, final KeyValueStore inner, this.time = time; this.group = group; + this.topic = name; + this.metrics = context.metrics(); + this.partition = context.id(); + this.context = context; + this.putTime = createSensor(name, "put"); this.getTime = createSensor(name, "get"); this.deleteTime = createSensor(name, "delete"); @@ -74,12 +79,6 @@ public MeteredKeyValueStore(final String name, final KeyValueStore inner, this.rangeTime = createSensor(name, "range"); this.flushTime = createSensor(name, "flush"); this.restoreTime = createSensor(name, "restore"); - this.metrics = context.metrics(); - - this.topic = name; - this.partition = context.id(); - - this.context = context; this.dirty = new HashSet(); this.maxDirty = 100; // TODO: this needs to be configurable