chia7712 commented on a change in pull request #9696: URL: https://github.com/apache/kafka/pull/9696#discussion_r538125351
########## File path: streams/src/main/java/org/apache/kafka/streams/processor/internals/metrics/StreamsMetricsImpl.java ########## @@ -235,11 +235,12 @@ public final Sensor threadLevelSensor(final String threadId, final String key = threadSensorPrefix(threadId); synchronized (threadLevelSensors) { final String fullSensorName = key + SENSOR_NAME_DELIMITER + sensorName; - return Optional.ofNullable(metrics.getSensor(fullSensorName)) - .orElseGet(() -> { - threadLevelSensors.computeIfAbsent(key, ignored -> new LinkedList<>()).push(fullSensorName); - return metrics.sensor(fullSensorName, recordingLevel, parents); - }); + final Sensor sensor = metrics.getSensor(fullSensorName); + if (sensor == null) { + threadLevelSensors.computeIfAbsent(key, ignored -> new LinkedList<>()).push(fullSensorName); Review comment: It seems the number of elements is always 1. Is ```new ArrayDeque<>(1)``` more suitable for this case? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org