From d0316030152b6eeb737110fee60e0e0d03138835 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Thu, 29 Mar 2007 00:44:16 +0000
Subject: [PATCH] Update the StaticUtils.stackTraceToSingleLineString method so that it produces more compact and more readable output.
---
opends/src/server/org/opends/server/util/StaticUtils.java | 76 +++++++++++++++++++++++++++++++-------
1 files changed, 62 insertions(+), 14 deletions(-)
diff --git a/opends/src/server/org/opends/server/util/StaticUtils.java b/opends/src/server/org/opends/server/util/StaticUtils.java
index 0a29a58..4bde017 100644
--- a/opends/src/server/org/opends/server/util/StaticUtils.java
+++ b/opends/src/server/org/opends/server/util/StaticUtils.java
@@ -34,6 +34,7 @@
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.nio.ByteBuffer;
import java.text.ParseException;
import java.util.ArrayList;
@@ -1462,21 +1463,8 @@
return;
}
- buffer.append(t);
-
- for (StackTraceElement e : t.getStackTrace())
+ if (DynamicConstants.DEBUG_BUILD)
{
- buffer.append(" / ");
- buffer.append(e.getFileName());
- buffer.append(":");
- buffer.append(e.getLineNumber());
- }
-
- while (t.getCause() != null)
- {
- t = t.getCause();
-
- buffer.append("; caused by ");
buffer.append(t);
for (StackTraceElement e : t.getStackTrace())
@@ -1486,6 +1474,66 @@
buffer.append(":");
buffer.append(e.getLineNumber());
}
+
+ while (t.getCause() != null)
+ {
+ t = t.getCause();
+
+ buffer.append("; caused by ");
+ buffer.append(t);
+
+ for (StackTraceElement e : t.getStackTrace())
+ {
+ buffer.append(" / ");
+ buffer.append(e.getFileName());
+ buffer.append(":");
+ buffer.append(e.getLineNumber());
+ }
+ }
+ }
+ else
+ {
+ if ((t instanceof InvocationTargetException) && (t.getCause() != null))
+ {
+ t = t.getCause();
+ }
+
+ String message = t.getMessage();
+ if ((message == null) || (message.length() == 0))
+ {
+ String className = t.getClass().getName();
+ try
+ {
+ className = className.substring(className.lastIndexOf('.') + 1);
+ } catch (Exception e) {}
+ buffer.append(className);
+ }
+ else
+ {
+ buffer.append(message);
+ }
+
+ int i=0;
+ buffer.append("(");
+ for (StackTraceElement e : t.getStackTrace())
+ {
+ if (i > 4)
+ {
+ buffer.append(" ...");
+ break;
+ }
+ else if (i > 0)
+ {
+ buffer.append(" ");
+ }
+
+ buffer.append(e.getFileName());
+ buffer.append(":");
+ buffer.append(e.getLineNumber());
+ i++;
+ }
+
+ buffer.append(")");
}
}
--
Gitblit v1.10.0