Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1705,10 +1705,12 @@ public void shutdown() {
this.interrupt();
getElectionAlg().shutdown();
}
try {
zkDb.close();
} catch (IOException ie) {
LOG.warn("Error closing logs ", ie);
if (zkDb != null) {
try {
zkDb.close();
} catch (IOException ie) {
LOG.warn("Error closing logs ", ie);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.zookeeper.server.quorum;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -80,6 +81,12 @@ public void testQuorumPeerListendOnSpecifiedClientIP(@TempDir File dataDir) thro
peer2.shutdown();
}

@Test
public void testShutdownWithoutZkDbDoesNotThrow() throws Exception {
QuorumPeer peer = new QuorumPeer();
assertDoesNotThrow(peer::shutdown);
Copy link
Copy Markdown
Contributor

@PDavid PDavid Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for trying this out. 👍

I think this should have worked, just you have to add a static import for org.junit.jupiter.api.Assertions.assertDoesNotThrow next to the already existing static imports, e.g.:

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

}

@Test
public void testProcessReconfigWillRecreateSocketAddresses() throws IOException {
QuorumPeerConfig.setReconfigEnabled(true);
Expand Down