[Libreoffice-commits] core.git: scripting/java

Stephan Bergmann sbergman at redhat.com
Mon Feb 16 02:27:44 PST 2015


 scripting/java/com/sun/star/script/framework/log/LogUtils.java |   31 +---------
 1 file changed, 6 insertions(+), 25 deletions(-)

New commits:
commit f1f6edaae13c9591e391d52856c31c6cdc303f3e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Feb 16 11:26:45 2015 +0100

    Make LogUtils.getTrace actually work
    
    Change-Id: I59e2b93ed1142bac22ead08cc101e27cfa3e02df

diff --git a/scripting/java/com/sun/star/script/framework/log/LogUtils.java b/scripting/java/com/sun/star/script/framework/log/LogUtils.java
index 183f94a..cd42b9d 100644
--- a/scripting/java/com/sun/star/script/framework/log/LogUtils.java
+++ b/scripting/java/com/sun/star/script/framework/log/LogUtils.java
@@ -18,8 +18,8 @@
 
 package com.sun.star.script.framework.log;
 
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
+import java.io.StringWriter;
+import java.io.PrintWriter;
 
 public class LogUtils {
 
@@ -50,27 +50,8 @@ public class LogUtils {
     }
 
     public static String getTrace(Exception e) {
-        ByteArrayOutputStream baos = null;
-        PrintStream ps = null;
-        String result = "";
-
-        try {
-            baos = new ByteArrayOutputStream();
-            ps = new PrintStream(baos);
-            e.printStackTrace(ps);
-        } finally {
-            try {
-                if (baos != null) {
-                    baos.close();
-                }
-
-                if (ps != null) {
-                    ps.close();
-                }
-            } catch (Exception excp) {
-            }
-        }
-
-        return result;
+        StringWriter w = new StringWriter();
+        e.printStackTrace(new PrintWriter(w));
+        return w.toString();
     }
-}
\ No newline at end of file
+}


More information about the Libreoffice-commits mailing list