Fixed NPE getting Stack Trace if Throwable is null #733

Simplify.
This commit is contained in:
Gary Gregory 2022-04-03 17:13:23 -04:00
parent 85c70a450c
commit 517a9e0630
1 changed files with 5 additions and 5 deletions

View File

@ -371,12 +371,12 @@ public class ExceptionUtils {
* {@code printStackTrace(PrintWriter)} method, or an empty String if {@code null} input
*/
public static String getStackTrace(final Throwable throwable) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw, true);
if (throwable != null) {
throwable.printStackTrace(pw);
if (throwable == null) {
return StringUtils.EMPTY;
}
return sw.getBuffer().toString();
final StringWriter sw = new StringWriter();
throwable.printStackTrace(new PrintWriter(sw, true));
return sw.toString();
}
/**