mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
24.41.2007 74a8448e45dbeba4803e92851f8a3023e038509b
Fix for issue 1448 (closing the status panel causes I/O Error in opends)

The message has been improved on the server side, but however the code of statuspanel has been modified to explicitly call the method close of the different DirContext objects when they are no longer used.
4 files modified
64 ■■■■ changed files
opends/src/statuspanel/org/opends/statuspanel/ConfigFromLDAP.java 17 ●●●●● patch | view | raw | blame | history
opends/src/statuspanel/org/opends/statuspanel/ServerStatusPooler.java 33 ●●●● patch | view | raw | blame | history
opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java 1 ●●●● patch | view | raw | blame | history
opends/src/statuspanel/org/opends/statuspanel/ui/LoginDialog.java 13 ●●●● patch | view | raw | blame | history
opends/src/statuspanel/org/opends/statuspanel/ConfigFromLDAP.java
@@ -125,6 +125,23 @@
  }
  /**
   * Method to be called to close properly the connection.
   */
  public void closeConnection()
  {
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
  }
  /**
   * Reads the configuration and monitoring information of the server using
   * LDAP.
   * When calling this method the thread is blocked until all the configuration
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();
    }
opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java
@@ -178,6 +178,7 @@
   */
  public void quitClicked()
  {
    serverStatusPooler.stopPooling();
    System.exit(0);
  }
opends/src/statuspanel/org/opends/statuspanel/ui/LoginDialog.java
@@ -327,10 +327,9 @@
      public Object processBackgroundTask() throws NamingException
      {
        Boolean isServerRunning = Boolean.TRUE;
        InitialLdapContext ctx = null;
        try
        {
          InitialLdapContext ctx = null;
          String ldapUrl = getLDAPURL();
          if (ldapUrl != null)
@@ -369,6 +368,16 @@
        {
          throw new IllegalStateException("Unexpected throwable.", t);
        }
        if (ctx != null)
        {
          try
          {
            ctx.close();
          }
          catch (Throwable t)
          {
          }
        }
        return isServerRunning;
      }