You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/04/27 20:28:13 UTC
svn commit: r1590446 -
/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Throwables.java
Author: mattsicker
Date: Sun Apr 27 18:28:13 2014
New Revision: 1590446
URL: http://svn.apache.org/r1590446
Log:
Make this a utility class.
- final with private constructor.
- make sure reader is closed
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Throwables.java
Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Throwables.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Throwables.java?rev=1590446&r1=1590445&r2=1590446&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Throwables.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Throwables.java Sun Apr 27 18:28:13 2014
@@ -28,11 +28,14 @@ import java.util.List;
/**
* Helps with Throwable objects.
*/
-public class Throwables {
+public final class Throwables {
+
+ private Throwables() {
+ }
/**
- * Converts a Throwable into a List of Strings
- *
+ * Converts a Throwable stack trace into a List of Strings
+ *
* @param throwable
* the Throwable
* @return a List of Strings
@@ -46,8 +49,8 @@ public class Throwables {
// Ignore any exceptions.
}
pw.flush();
+ final List<String> lines = new ArrayList<String>();
final LineNumberReader reader = new LineNumberReader(new StringReader(sw.toString()));
- final ArrayList<String> lines = new ArrayList<String>();
try {
String line = reader.readLine();
while (line != null) {
@@ -59,6 +62,8 @@ public class Throwables {
Thread.currentThread().interrupt();
}
lines.add(ex.toString());
+ } finally {
+ Closer.closeSilent(reader);
}
return lines;
}