Ver código fonte

Fix a bug where server shutdown threw a NullPointerException.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@417261 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 19 anos atrás
pai
commit
197515dcd9
1 arquivos alterados com 10 adições e 9 exclusões
  1. 10 9
      src/java/org/apache/hadoop/ipc/Server.java

+ 10 - 9
src/java/org/apache/hadoop/ipc/Server.java

@@ -233,15 +233,15 @@ public abstract class Server {
       LOG.info("Stopping " + this.getName());
       LOG.info("Stopping " + this.getName());
 
 
       try {
       try {
-        if (acceptChannel != null)
-          acceptChannel.close();
-        if (selector != null)
-          selector.close();
+        acceptChannel.close();
+        selector.close();
       } catch (IOException e) { }
       } catch (IOException e) { }
 
 
-      selector= null;
-      acceptChannel= null;
-      connectionList = null;
+      synchronized (this) {
+        selector= null;
+        acceptChannel= null;
+        connectionList = null;
+      }
     }
     }
 
 
     private void closeCurrentConnection(SelectionKey key, Throwable e) {
     private void closeCurrentConnection(SelectionKey key, Throwable e) {
@@ -311,10 +311,11 @@ public abstract class Server {
       }
       }
     }   
     }   
 
 
-    void doStop()
-    {
+    synchronized void doStop() {
+      if (selector != null) {
         selector.wakeup();
         selector.wakeup();
         Thread.yield();
         Thread.yield();
+      }
     }
     }
   }
   }