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 <mjsax@apache.org>, runo Cadonna <cadonna@apache.org>, Lucas Brutschy <lbrutschy@confluent.io>, Bill Bejeck <bbejeck@gmail.com>
This commit is contained in:
A. Sophie Blee-Goldman 2024-12-13 20:36:08 -08:00 committed by GitHub
parent f2f19b7ad9
commit 91575892d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View File

@ -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. " +

View File

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