Author: borges
Date: 2011-11-18 05:45:41 -0500 (Fri, 18 Nov 2011)
New Revision: 11703
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
HORNETQ-761 Fix NPE in case of race between multiple calls to stop()
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-11-18
10:45:26 UTC (rev 11702)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-11-18
10:45:41 UTC (rev 11703)
@@ -577,36 +577,39 @@
postOffice.stop();
}
- List<Runnable> tasks = scheduledPool.shutdownNow();
+ if (scheduledPool != null)
+ {
+ List<Runnable> tasks = scheduledPool.shutdownNow();
+ for (Runnable task : tasks)
+ {
+ HornetQServerImpl.log.info(this + "::Waiting for " + task);
+ }
+ }
- for (Runnable task : tasks)
- {
- HornetQServerImpl.log.info(this + "::Waiting for " + task);
- }
-
if (memoryManager != null)
{
memoryManager.stop();
}
- threadPool.shutdown();
- scheduledPool.shutdown();
-
- try
- {
- if (!threadPool.awaitTermination(10, TimeUnit.SECONDS))
+ if (threadPool != null)
{
- HornetQServerImpl.log.warn("Timed out waiting for pool to
terminate");
+ threadPool.shutdown();
+ try
+ {
+ if (!threadPool.awaitTermination(10, TimeUnit.SECONDS))
+ {
+ HornetQServerImpl.log.warn("Timed out waiting for pool to
terminate");
+ }
+ }
+ catch (InterruptedException e)
+ {
+ // Ignore
+ }
+ threadPool = null;
}
- }
- catch (InterruptedException e)
- {
- // Ignore
- }
- threadPool = null;
- try
+ try
{
if (!scheduledPool.awaitTermination(10, TimeUnit.SECONDS))
{
@@ -621,7 +624,6 @@
securityStore.stop();
threadPool = null;
-
scheduledPool = null;
pagingManager = null;