From 11f3393f06059157c150318367fb15d0a4e4e707 Mon Sep 17 00:00:00 2001 From: rangao Date: Wed, 12 Jul 2023 11:36:00 +0800 Subject: [PATCH] revert spotbugs problem change --- ...TopicProducerStateManagerSnapshotBuffer.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/storage/PulsarTopicProducerStateManagerSnapshotBuffer.java b/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/storage/PulsarTopicProducerStateManagerSnapshotBuffer.java index d7b8f2fa42..887d4502ca 100644 --- a/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/storage/PulsarTopicProducerStateManagerSnapshotBuffer.java +++ b/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/storage/PulsarTopicProducerStateManagerSnapshotBuffer.java @@ -83,18 +83,11 @@ private synchronized void discardReader(Reader oldReader) { if (reader == null) { return; } - if (reader.isDone() && !reader.isCompletedExceptionally()) { - Reader newReader = null; - try { - newReader = reader.get(0, TimeUnit.MILLISECONDS); - if (newReader == oldReader) { - log.info("discard broken reader for {}", topic); - reader = null; - } - } catch (Exception exception) { - log.warn("Failed to get reader handle for topic {}, discard the reader.", topic, exception); - reader = null; - } + if (reader.isCompletedExceptionally() || (reader.isDone() + && !reader.isCompletedExceptionally() + && reader.getNow(null) == oldReader)) { + log.info("discard broken reader for {}", topic); + reader = null; } }