From 6195e8a865036c0577e6e91239703cbc0e559754 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Tue, 24 Apr 2007 15:41:08 +0000
Subject: [PATCH] Fix for issue 1448 (closing the status panel causes I/O Error in opends)

---
 opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusPooler.java |   33 ++++++++++++++++++++++++++-------
 1 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusPooler.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusPooler.java
index 993b10e..a56274c 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusPooler.java
+++ b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusPooler.java
@@ -49,7 +49,7 @@
   private String pwd;
   private ServerStatusDescriptor lastDescriptor;
   private boolean stopPooling;
-  private Thread t;
+  private Thread poolingThread;
   private HashSet<ServerStatusChangeListener> listeners =
     new HashSet<ServerStatusChangeListener>();
   private boolean starting;
@@ -83,7 +83,7 @@
   public void startPooling()
   {
     stopPooling = false;
-    t = new Thread(new Runnable()
+    poolingThread = new Thread(new Runnable()
     {
       public void run()
       {
@@ -133,7 +133,25 @@
         }
       }
     });
-    t.start();
+    poolingThread.start();
+  }
+
+  /**
+   * Stop pooling the server status.  This method does not block the thread
+   * that called it.
+   *
+   */
+  public void stopPooling()
+  {
+    stopPooling = true;
+    try
+    {
+      onLineConf.closeConnection();
+      poolingThread.interrupt();
+    }
+    catch (Throwable t)
+    {
+    }
   }
 
   /**
@@ -218,7 +236,8 @@
   {
     this.dn = dn;
     this.pwd = pwd;
-    if ((ldapUrl != null) && (t != null) && t.isAlive() && !stopPooling)
+    if ((ldapUrl != null) && (poolingThread != null) &&
+        poolingThread.isAlive() && !stopPooling)
     {
       /* If we are pooling, stop the pooling update the connection information
        * and restart the pooling.  Set the stopPooling boolean to true to
@@ -227,17 +246,17 @@
        *
        */
       stopPooling = true;
-      t.interrupt();
+      poolingThread.interrupt();
       try
       {
-        t.join(5000);
+        poolingThread.join(5000);
       }
       catch (Throwable t)
       {
         /* This should not happen: this thread should not be interrupted. */
         t.printStackTrace();
       }
-      t = null;
+      poolingThread = null;
       onLineConf.setConnectionInfo(ldapUrl, dn, pwd);
       startPooling();
     }

--
Gitblit v1.10.0