drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meh...@apache.org
Subject drill git commit: DRILL-2625: StackTrace format to match JDK's Throwable's format closes #109
Date Thu, 13 Aug 2015 21:06:55 GMT
Repository: drill
Updated Branches:
  refs/heads/master 1cfbe7de9 -> c0060f7f5


DRILL-2625: StackTrace format to match JDK's Throwable's format
closes #109


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/c0060f7f
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/c0060f7f
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/c0060f7f

Branch: refs/heads/master
Commit: c0060f7f54d2b5c3f5ce7513e15fba43c0029933
Parents: 1cfbe7d
Author: Chris Westin <cwestin@yahoo.com>
Authored: Wed Aug 12 10:22:05 2015 -0700
Committer: Mehant Baid <mehantr@gmail.com>
Committed: Thu Aug 13 13:19:56 2015 -0700

----------------------------------------------------------------------
 .../org/apache/drill/common/StackTrace.java     | 40 +++++++++-----------
 1 file changed, 18 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/c0060f7f/common/src/main/java/org/apache/drill/common/StackTrace.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/StackTrace.java b/common/src/main/java/org/apache/drill/common/StackTrace.java
index 54068ec..de64ed7 100644
--- a/common/src/main/java/org/apache/drill/common/StackTrace.java
+++ b/common/src/main/java/org/apache/drill/common/StackTrace.java
@@ -17,9 +17,6 @@
  */
 package org.apache.drill.common;
 
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
 import java.util.Arrays;
 
 /**
@@ -38,36 +35,35 @@ public class StackTrace {
   }
 
   /**
-   * Write the stack trace.
+   * Write the stack trace to a StringBuilder.
    *
-   * @param writer where to write it
+   * @param sb where to write it
    * @param indent how many spaces to indent each line
    */
-  public void write(final Writer writer, final int indent) {
+  public void writeToBuilder(final StringBuilder sb, final int indent) {
     // create the indentation string
     final char[] indentation = new char[indent];
     Arrays.fill(indentation, ' ');
 
-    try {
-      // write the stack trace
-      for(StackTraceElement ste : stackTraceElements) {
-        writer.write(indentation);
-        writer.write(ste.getClassName());
-        writer.write('.');
-        writer.write(ste.getMethodName());
-        writer.write(':');
-        writer.write(Integer.toString(ste.getLineNumber()));
-        writer.write('\n');
-      }
-    } catch(IOException e) {
-      throw new RuntimeException("couldn't write", e);
+    // write the stack trace in standard Java format
+    for(StackTraceElement ste : stackTraceElements) {
+      sb.append(indentation)
+          .append("at ")
+          .append(ste.getClassName())
+          .append('.')
+          .append(ste.getMethodName())
+          .append('(')
+          .append(ste.getFileName())
+          .append(':')
+          .append(Integer.toString(ste.getLineNumber()))
+          .append(")\n");
     }
   }
 
   @Override
   public String toString() {
-    final StringWriter sw = new StringWriter();
-    write(sw, 0);
-    return sw.toString();
+    final StringBuilder sb = new StringBuilder();
+    writeToBuilder(sb, 0);
+    return sb.toString();
   }
 }


Mime
View raw message