You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by "seekskyworld (via GitHub)" <gi...@apache.org> on 2026/01/14 07:59:34 UTC

[PR] ZOOKEEPER-5012: guard zkDb close in QuorumPeer shutdown [zookeeper]

seekskyworld opened a new pull request, #2345:
URL: https://github.com/apache/zookeeper/pull/2345

   Issue: https://issues.apache.org/jira/browse/ZOOKEEPER-5012
   
   Summary
   - Guard zkDb close in QuorumPeer.shutdown when initialization did not finish.
   - Add a QuorumPeerTest regression for shutdown without zkDb.
   
   Motivation
   - During restart, shutdown can run before zkDb is initialized; avoid NPE while preserving cleanup.
   
   Validation
   - mvn -pl zookeeper-server -Dtest=QuorumPeerTest#testShutdownWithoutZkDbDoesNotThrow test


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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZOOKEEPER-5012: guard zkDb close in QuorumPeer shutdown [zookeeper]

Posted by "seekskyworld (via GitHub)" <gi...@apache.org>.
seekskyworld commented on PR #2345:
URL: https://github.com/apache/zookeeper/pull/2345#issuecomment-3919262057

   @PDavid  I made two changes: replaced assertDoesNotThrow with a JUnit‑compatible try/catch to keep the “no exception” assertion, and added the missing fail static import so the test compiles.


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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZOOKEEPER-5012: guard zkDb close in QuorumPeer shutdown [zookeeper]

Posted by "seekskyworld (via GitHub)" <gi...@apache.org>.
seekskyworld commented on PR #2345:
URL: https://github.com/apache/zookeeper/pull/2345#issuecomment-3918992344

   @PDavid I agree with you. It looks great


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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZOOKEEPER-5012: guard zkDb close in QuorumPeer shutdown [zookeeper]

Posted by "PDavid (via GitHub)" <gi...@apache.org>.
PDavid commented on code in PR #2345:
URL: https://github.com/apache/zookeeper/pull/2345#discussion_r2821179181


##########
zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumPeerTest.java:
##########
@@ -83,7 +83,7 @@ public void testQuorumPeerListendOnSpecifiedClientIP(@TempDir File dataDir) thro
     @Test
     public void testShutdownWithoutZkDbDoesNotThrow() throws Exception {
         QuorumPeer peer = new QuorumPeer();
-        peer.shutdown();
+        assertDoesNotThrow(peer::shutdown);

Review Comment:
   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;
   ```



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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZOOKEEPER-5012: guard zkDb close in QuorumPeer shutdown [zookeeper]

Posted by "PDavid (via GitHub)" <gi...@apache.org>.
PDavid commented on code in PR #2345:
URL: https://github.com/apache/zookeeper/pull/2345#discussion_r2817074295


##########
zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumPeerTest.java:
##########
@@ -80,6 +80,12 @@ public void testQuorumPeerListendOnSpecifiedClientIP(@TempDir File dataDir) thro
         peer2.shutdown();
     }
 
+    @Test
+    public void testShutdownWithoutZkDbDoesNotThrow() throws Exception {
+        QuorumPeer peer = new QuorumPeer();
+        peer.shutdown();

Review Comment:
   Minor idea: Maybe we could use `assertDoesNotThrow()` to signify which method should not throw an Exception.
   
   ```suggestion
           assertDoesNotThrow(peer::shutdown);
   ```



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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZOOKEEPER-5012: guard zkDb close in QuorumPeer shutdown [zookeeper]

Posted by "PDavid (via GitHub)" <gi...@apache.org>.
PDavid commented on code in PR #2345:
URL: https://github.com/apache/zookeeper/pull/2345#discussion_r2821179181


##########
zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumPeerTest.java:
##########
@@ -83,7 +83,7 @@ public void testQuorumPeerListendOnSpecifiedClientIP(@TempDir File dataDir) thro
     @Test
     public void testShutdownWithoutZkDbDoesNotThrow() throws Exception {
         QuorumPeer peer = new QuorumPeer();
-        peer.shutdown();
+        assertDoesNotThrow(peer::shutdown);

Review Comment:
   Thanks for trying this out. :+1: 
   
   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;
   ```



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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZOOKEEPER-5012: guard zkDb close in QuorumPeer shutdown [zookeeper]

Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar merged PR #2345:
URL: https://github.com/apache/zookeeper/pull/2345


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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZOOKEEPER-5012: guard zkDb close in QuorumPeer shutdown [zookeeper]

Posted by "seekskyworld (via GitHub)" <gi...@apache.org>.
seekskyworld commented on PR #2345:
URL: https://github.com/apache/zookeeper/pull/2345#issuecomment-3919859415

   @PDavid You're right. I didn't notice that the import wasn't included in the proposal. It has now been corrected.


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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZOOKEEPER-5012: guard zkDb close in QuorumPeer shutdown [zookeeper]

Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar commented on PR #2345:
URL: https://github.com/apache/zookeeper/pull/2345#issuecomment-3928121290

   Merged to master branch. Thanks @seekskyworld !


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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZOOKEEPER-5012: guard zkDb close in QuorumPeer shutdown [zookeeper]

Posted by "seekskyworld (via GitHub)" <gi...@apache.org>.
seekskyworld commented on PR #2345:
URL: https://github.com/apache/zookeeper/pull/2345#issuecomment-3928342226

   @anmolnar @PDavid I have also submitted four PRS here. Maybe you can take a look


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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZOOKEEPER-5012: guard zkDb close in QuorumPeer shutdown [zookeeper]

Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar commented on PR #2345:
URL: https://github.com/apache/zookeeper/pull/2345#issuecomment-3929907394

   > @anmolnar @PDavid I have also submitted four PRS here. Maybe you can take a look
   
   Links?


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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org