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

jvergara
08.07.2007 fcbec9412762f65624a3a10cd2bb33cde37176f4
Fix for issue 1778 (setup fails during startup of directory server).

When we install OpenDS on windows with no Windows Service configured (this is the case where this issue was reproduced) and we launch start-ds.bat the BufferedOutputReaders are kept open. The fix consists of waiting at most a certain time once the server sent the msg ID informing that it was successfully started.
1 files modified
39 ■■■■ changed files
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java 39 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
@@ -303,7 +303,6 @@
    try
    {
      String startedId = getStartedId();
      Process process = pb.start();
      BufferedReader err =
@@ -314,6 +313,7 @@
      StartReader errReader = new StartReader(err, startedId, true);
      StartReader outputReader = new StartReader(out, startedId, false);
      long finishedTime = 0;
      while (!errReader.isFinished() || !outputReader.isFinished())
      {
        try
@@ -322,6 +322,25 @@
        } catch (InterruptedException ie)
        {
        }
        if (errReader.startedIdFound() || outputReader.startedIdFound())
        {
          /* When we start the server in windows and we are not running it
           * under a windows service, the readers are kept open forever.
           * Once we find that is finished, wait at most 7 seconds.
           */
          if (finishedTime == 0)
          {
            finishedTime = System.currentTimeMillis();
          }
          else
          {
            if (System.currentTimeMillis() - finishedTime > 7000)
            {
              break;
            }
          }
        }
      }
      // Collect any messages found in the output
@@ -532,6 +551,8 @@
    private boolean isFinished;
    private boolean startedIdFound;
    private boolean isFirstLine;
    /**
@@ -577,9 +598,10 @@
                isFirstLine = false;
              }
              LOG.log(Level.INFO, "server: " + line);
              if (line.indexOf("id=" + startedId) != -1)
              if (line.toLowerCase().indexOf("=" + startedId) != -1)
              {
                isFinished = true;
                startedIdFound = true;
              }
              messages.add(line);
@@ -624,10 +646,17 @@
    {
      return isFinished;
    }
  }
  private String getMsg(String key) {
    return ResourceProvider.getInstance().getMsg(key);
    /**
     * Returns <CODE>true</CODE> if the server start Id was found and
     * <CODE>false</CODE> otherwise.
     * @return <CODE>true</CODE> if the server start Id was found and
     * <CODE>false</CODE> otherwise.
     */
    public boolean startedIdFound()
    {
      return startedIdFound;
    }
  }
  private String getMsg(String key, String... args) {