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

jvergara
30.39.2007 767097d8baff57920038ea1f6e2e772d6612ea0c
Fix for issue 1409 (uncatch exceptions during setup if not enough swap space).

Identify if we are displaying an error generated by memory shortage and have a particular message for it.
3 files modified
48 ■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java 4 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties 2 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java 42 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
@@ -120,10 +120,6 @@
    } catch (QuickSetupException ex)
    {
      if (ex.getCause() != null)
      {
        ex.getCause().printStackTrace();
      }
      status = InstallProgressStep.FINISHED_WITH_ERROR;
      String html = getFormattedError(ex, true);
      notifyListeners(html);
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -593,6 +593,8 @@
error-copying=An unexpected error occurred extracting file {0}.
error-zip-stream=An unexpected error occurred reading the zip file {0}.
exception-details=Details: {0}
exception-out-of-memory-details=Not enough memory to perform the operation.  \
Details: {0}
downloading-error=An error occurred downloading remote file(s) {0}.
error-zipinputstreamnull=Could not retrieve zip file {0}.  The input stream \
is null.
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -722,12 +722,21 @@
      msg = i18n.getMsg(key);
    }
    String tag;
    if (isOutOfMemory(t))
    {
      tag = "exception-out-of-memory-details";
    }
    else
    {
      tag = "exception-details";
    }
    String detail = t.toString();
    if (detail != null)
    {
      String[] arg =
        { detail };
      msg = msg + "  " + i18n.getMsg("exception-details", arg);
      { detail };
      msg = msg + "  " + i18n.getMsg(tag, arg);
    }
    return msg;
  }
@@ -1438,4 +1447,33 @@
    System.setProperty("com.apple.mrj.application.apple.menu.about.name",
                       appName);
  }
  /**
    * Tells whether this throwable has been generated for an out of memory
    * error or not.
    * @param t the throwable to analyze.
    * @return <CODE>true</CODE> if the throwable was generated by an out of
    * memory error and false otherwise.
    */
  private static boolean isOutOfMemory(Throwable t)
  {
    boolean isOutOfMemory = false;
    while (!isOutOfMemory && (t != null))
    {
      if (t instanceof OutOfMemoryError)
      {
        isOutOfMemory = true;
      }
      else if (t instanceof IOException)
      {
        String msg = t.toString();
        if (msg != null)
        {
          isOutOfMemory = msg.indexOf("Not enough space") != -1;
        }
      }
      t = t.getCause();
    }
    return isOutOfMemory;
  }
}