mirror of https://github.com/apache/kafka.git
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:
parent
f2f19b7ad9
commit
91575892d2
|
@ -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. " +
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue