From 767097d8baff57920038ea1f6e2e772d6612ea0c Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 29 Mar 2007 22:39:31 +0000
Subject: [PATCH] Fix for issue 1409 (uncatch exceptions during setup if not enough swap space).
---
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties | 2 ++
opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java | 4 ----
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 42 ++++++++++++++++++++++++++++++++++++++++--
3 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java b/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
index 58e63c2..ec3d44c 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
+++ b/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);
diff --git a/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties b/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
index 19be787..ccf5261 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
+++ b/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.
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 5b794c4..ca80024 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/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;
+ }
}
--
Gitblit v1.10.0