Skip to content

Commit

Permalink
HOTFIX: RocksDBMetricsRecorder#init should null check taskId (apache#…
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
ableegoldman authored Dec 14, 2024
1 parent f2f19b7 commit 9157589
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public TaskId taskId() {
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. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ public void shouldThrowIfMetricRecorderIsReInitialisedWithDifferentTask() {
);
}

@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(
Expand Down

0 comments on commit 9157589

Please sign in to comment.