mirror of https://github.com/apache/kafka.git
KAFKA-19676 EpochState should override close to avoid throwing IOException (#20508)
Jira: [KAFKA-19676](https://issues.apache.org/jira/browse/KAFKA-19676) All subclasses of EpochState do not throw an IOException when closing, so catching it is unnecessary. We could override close to remove the IOException declaration. Reviewers: Jhen-Yung Hsu <jhenyunghsu@gmail.com>, TaiJuWu <tjwu1217@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
865beb6ede
commit
8a79ea2e5b
|
@ -59,4 +59,11 @@ public interface EpochState extends Closeable {
|
|||
* User-friendly description of the state
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Since all subclasses implement the Closeable interface while none throw any IOException,
|
||||
* this implementation is provided to eliminate the need for exception handling in the close operation.
|
||||
*/
|
||||
@Override
|
||||
void close();
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@ import org.apache.kafka.server.common.OffsetAndEpoch;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
|
@ -736,12 +734,7 @@ public class QuorumState {
|
|||
|
||||
private void memoryTransitionTo(EpochState newState) {
|
||||
if (state != null) {
|
||||
try {
|
||||
state.close();
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(
|
||||
"Failed to transition from " + state.name() + " to " + newState.name(), e);
|
||||
}
|
||||
state.close();
|
||||
}
|
||||
|
||||
EpochState from = state;
|
||||
|
|
Loading…
Reference in New Issue