MarcoLotz commented on a change in pull request #10042:
URL: https://github.com/apache/kafka/pull/10042#discussion_r571617491



##########
File path: core/src/main/scala/kafka/tools/StreamsResetter.java
##########
@@ -503,7 +505,15 @@ private void resetToDatetime(final Consumer<byte[], 
byte[]> client,
         final Map<TopicPartition, OffsetAndTimestamp> topicPartitionsAndOffset 
= client.offsetsForTimes(topicPartitionsAndTimes);
 
         for (final TopicPartition topicPartition : inputTopicPartitions) {
-            client.seek(topicPartition, 
topicPartitionsAndOffset.get(topicPartition).offset());
+            final Optional<Long> partitionOffset = 
Optional.ofNullable(topicPartitionsAndOffset.get(topicPartition))
+                    .map(OffsetAndTimestamp::offset);

Review comment:
       You are right. ListOffsetsResponse.UNKNOWN_OFFSET value is -1. Clearly 
it's not enough to check if it is null (the cause of the NPE bug) but also we 
need to make sure that it is not ListOffsetsResponse.UNKNOWN_OFFSET value.
   
   I have added a filter to the Optional.




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


Reply via email to