From 68d098fbef58f41f6bea48f87d7f38fea9acf87a Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Mon, 26 Sep 2011 04:13:38 +0000 Subject: [PATCH] it's possible to get an NPE here on shutdown in tests git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1175656 13f79535-47bb-0310-9956-ffa450edef68 --- solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java b/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java index e5dcfed39fe..06afd547162 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java +++ b/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java @@ -35,6 +35,7 @@ import org.apache.solr.SolrTestCaseJ4; import org.apache.zookeeper.jmx.ManagedUtil; import org.apache.zookeeper.server.NIOServerCnxn; import org.apache.zookeeper.server.ServerConfig; +import org.apache.zookeeper.server.ZKDatabase; import org.apache.zookeeper.server.ZooKeeperServer; import org.apache.zookeeper.server.SessionTracker.Session; import org.apache.zookeeper.server.persistence.FileTxnSnapLog; @@ -108,7 +109,10 @@ public class ZkTestServer { */ protected void shutdown() throws IOException { zooKeeperServer.shutdown(); - zooKeeperServer.getZKDatabase().close(); + ZKDatabase zkDb = zooKeeperServer.getZKDatabase(); + if (zkDb != null) { + zkDb.close(); + } waitForServerDown(getZkHost() + ":" + getPort(), 5000); cnxnFactory.shutdown(); }