You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2020/06/25 01:17:09 UTC

[curator] branch CURATOR-575-fix-testing-server-npe updated (c439f38 -> 1039117)

This is an automated email from the ASF dual-hosted git repository.

randgalt pushed a change to branch CURATOR-575-fix-testing-server-npe
in repository https://gitbox.apache.org/repos/asf/curator.git.


 discard c439f38  CURATOR-575 - TestingServer shutdown can cause an NPW due to FileTxnSnapLog being closed in a different thread
     new 1039117  CURATOR-575 - TestingServer shutdown can cause an NPE due to FileTxnSnapLog being closed in a different thread

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (c439f38)
            \
             N -- N -- N   refs/heads/CURATOR-575-fix-testing-server-npe (1039117)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[curator] 01/01: CURATOR-575 - TestingServer shutdown can cause an NPE due to FileTxnSnapLog being closed in a different thread

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

randgalt pushed a commit to branch CURATOR-575-fix-testing-server-npe
in repository https://gitbox.apache.org/repos/asf/curator.git

commit 103911752468a133f44020d8f8dd355f8d0ff602
Author: randgalt <ra...@apache.org>
AuthorDate: Wed Jun 24 20:15:40 2020 -0500

    CURATOR-575 - TestingServer shutdown can cause an NPE due to FileTxnSnapLog being closed in a different thread
---
 .../apache/curator/test/TestingZooKeeperMain.java  | 24 ++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
index d53fb08..cdf59d0 100644
--- a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
+++ b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
@@ -226,13 +226,12 @@ public class TestingZooKeeperMain implements ZooKeeperMainFace
     private void internalRunFromConfig(ServerConfig config) throws IOException
     {
         log.info("Starting server");
-        FileTxnSnapLog txnLog = null;
         try {
             // Note that this thread isn't going to be doing anything else,
             // so rather than spawning another thread, we will just call
             // run() in this thread.
             // create a file logger url from the command line args
-            txnLog = new FileTxnSnapLog(config.getDataLogDir(), config.getDataDir());
+            FileTxnSnapLog txnLog = new FileTxnSnapLog(config.getDataLogDir(), config.getDataDir());
             zkServer = new TestZooKeeperServer(txnLog, config);
 
             try
@@ -261,22 +260,35 @@ public class TestingZooKeeperMain implements ZooKeeperMainFace
             // warn, but generally this is ok
             Thread.currentThread().interrupt();
             log.warn("Server interrupted", e);
-        } finally {
-            if (txnLog != null) {
-                txnLog.close();
-            }
         }
     }
 
     public static class TestZooKeeperServer extends ZooKeeperServer
     {
+        private final FileTxnSnapLog txnLog;
+
         public TestZooKeeperServer(FileTxnSnapLog txnLog, ServerConfig config)
         {
+            this.txnLog = txnLog;
             this.setTxnLogFactory(txnLog);
             this.setMinSessionTimeout(config.getMinSessionTimeout());
             this.setMaxSessionTimeout(config.getMaxSessionTimeout());
         }
 
+        @Override
+        public synchronized void shutdown(boolean fullyShutDown)
+        {
+            super.shutdown(fullyShutDown);
+            try
+            {
+                txnLog.close();
+            }
+            catch ( IOException e )
+            {
+                // ignore
+            }
+        }
+
         private final AtomicBoolean isRunning = new AtomicBoolean(false);
 
         public RequestProcessor getFirstProcessor()