This is an automated email from the ASF dual-hosted git repository.

ableegoldman pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 91575892d2f HOTFIX: RocksDBMetricsRecorder#init should null check 
taskId (#18151)
91575892d2f is described below

commit 91575892d2f3003bc406656200967e14d4216e04
Author: A. Sophie Blee-Goldman <[email protected]>
AuthorDate: Fri Dec 13 20:36:08 2024 -0800

    HOTFIX: RocksDBMetricsRecorder#init should null check taskId (#18151)
    
    Appears to be a typo in the code, since the error message indicates this 
check is for taskId being null, but instead we accidentally check the streams 
metrics twice
    
    Reviewers: Matthias Sax <[email protected]>, runo Cadonna 
<[email protected]>, Lucas Brutschy <[email protected]>, Bill Bejeck 
<[email protected]>
---
 .../state/internals/metrics/RocksDBMetricsRecorder.java  |  2 +-
 .../internals/metrics/RocksDBMetricsRecorderTest.java    | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git 
a/streams/src/main/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorder.java
 
b/streams/src/main/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorder.java
index fd7adab1b57..03b1f7eaf02 100644
--- 
a/streams/src/main/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorder.java
+++ 
b/streams/src/main/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorder.java
@@ -135,7 +135,7 @@ public class RocksDBMetricsRecorder {
     public void init(final StreamsMetricsImpl streamsMetrics,
                      final TaskId taskId) {
         Objects.requireNonNull(streamsMetrics, "Streams metrics must not be 
null");
-        Objects.requireNonNull(streamsMetrics, "task ID must not be null");
+        Objects.requireNonNull(taskId, "task ID must not be null");
         if (this.taskId != null && !this.taskId.equals(taskId)) {
             throw new IllegalStateException("Metrics recorder is 
re-initialised with different task: previous task is " +
                 this.taskId + " whereas current task is " + taskId + ". This 
is a bug in Kafka Streams. " +
diff --git 
a/streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorderTest.java
 
b/streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorderTest.java
index 7136ee66b2e..7ec3f4bf38c 100644
--- 
a/streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorderTest.java
+++ 
b/streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorderTest.java
@@ -173,6 +173,22 @@ public class RocksDBMetricsRecorderTest {
         );
     }
 
+    @Test
+    public void shouldThrowIfMetricRecorderIsInitialisedWithNullMetrics() {
+        assertThrows(
+            NullPointerException.class,
+            () -> recorder.init(null, TASK_ID1)
+        );
+    }
+
+    @Test
+    public void shouldThrowIfMetricRecorderIsInitialisedWithNullTaskId() {
+        assertThrows(
+            NullPointerException.class,
+            () -> recorder.init(streamsMetrics, null)
+        );
+    }
+
     @Test
     public void 
shouldThrowIfMetricRecorderIsReInitialisedWithDifferentStreamsMetrics() {
         assertThrows(

Reply via email to