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

jvergara
13.46.2009 1f3e78eae894cf7e4a542891dc43c03bb9149bf4
Fix for issue 4276 (java detection message cut off in the install log)

In the case of Windows, the options are tested using the script helpers. If there is an error these scripts require the user to provide some input. The fix consists on allowing the scripts to write the message to the process output and after that to kill the process (we used to kill the process right after detecting an error).
1 files modified
38 ■■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java 38 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -154,6 +154,8 @@
      String installPath)
  {
    boolean supported = false;
    LOG.log(Level.INFO, "Checking if options "+option+
        " are supported with java home: "+javaHome);
    try
    {
      List<String> args = new ArrayList<String>();
@@ -183,33 +185,45 @@
      {
        env.put("DO_NOT_PAUSE", "true");
      }
      Process process = pb.start();
      final Process process = pb.start();
      LOG.log(Level.INFO, "launching "+args+ " with env: "+env);
      InputStream is = process.getInputStream();
      BufferedReader reader = new BufferedReader(new InputStreamReader(is));
      String line;
      boolean errorDetected = false;
      while (null != (line = reader.readLine())) {
        LOG.log(Level.INFO, "The output: "+line);
        if (line.indexOf("ERROR:  The detected Java version") != -1)
        {
          try
          if (Utils.isWindows())
          {
            process.destroy();
            return false;
            // If we are running windows, the process get blocked waiting for
            // user input.  Just wait for a certain time to print the output
            // in the logger and then kill the process.
            Thread t = new Thread(new Runnable()
            {
              public void run()
              {
                try
                {
                  Thread.sleep(3000);
                  process.destroy();
                }
                catch (Throwable t)
                {
                }
              }
            });
            t.start();
          }
          catch (Throwable t)
          {
            return false;
          }
          finally
          {
          }
          errorDetected = true;
        }
      }
      process.waitFor();
      int returnCode = process.exitValue();
      LOG.log(Level.INFO, "returnCode: "+returnCode);
      supported = returnCode == 0;
      supported = returnCode == 0 && !errorDetected;
      LOG.log(Level.INFO, "supported: "+supported);
    }
    catch (Throwable t)
    {