This is an automated email from the ASF dual-hosted git repository.
ijuma pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/3.0 by this push:
new a03914e KAFKA-13262: Remove final from `MockConsumer.close()` and
delegate implementation (#11307)
a03914e is described below
commit a03914e4d8d6f4ed57ef9cd684d53f0662f5a1e7
Author: Ismael Juma <[email protected]>
AuthorDate: Tue Sep 7 12:06:03 2021 -0700
KAFKA-13262: Remove final from `MockConsumer.close()` and delegate
implementation (#11307)
I added the final via 2f3600198722 to catch overriding mistakes
since the implementation was moved from the deprecated and
overloaded `close` with two parameters to the no-arg
`close`.
I didn't realize then that `MockConsumer` is a public
API (seems like a bit of a mistake since we tweak the
implementation and sometimes adds methods without a KIP).
Given that this is a public API, I have also moved the implementation
of `close` to the one arg overload. This makes it easier for a
subclass to have specific overriding behavior depending on the
timeout.
Reviewers: David Jacot <[email protected]>
---
.../org/apache/kafka/clients/consumer/MockConsumer.java | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git
a/clients/src/main/java/org/apache/kafka/clients/consumer/MockConsumer.java
b/clients/src/main/java/org/apache/kafka/clients/consumer/MockConsumer.java
index ed29afe..b1fc7ec 100644
--- a/clients/src/main/java/org/apache/kafka/clients/consumer/MockConsumer.java
+++ b/clients/src/main/java/org/apache/kafka/clients/consumer/MockConsumer.java
@@ -45,6 +45,7 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static java.util.Collections.singleton;
+import static
org.apache.kafka.clients.consumer.KafkaConsumer.DEFAULT_CLOSE_TIMEOUT_MS;
/**
@@ -446,7 +447,12 @@ public class MockConsumer<K, V> implements Consumer<K, V> {
}
@Override
- public final synchronized void close() {
+ public void close() {
+ close(Duration.ofMillis(DEFAULT_CLOSE_TIMEOUT_MS));
+ }
+
+ @Override
+ public synchronized void close(Duration timeout) {
this.closed = true;
}
@@ -568,9 +574,4 @@ public class MockConsumer<K, V> implements Consumer<K, V> {
public Duration lastPollTimeout() {
return lastPollTimeout;
}
-
- @Override
- public void close(Duration timeout) {
- close();
- }
}