1 | package com.renomad.minum.utils; | |
2 | ||
3 | import java.io.PrintWriter; | |
4 | import java.io.StringWriter; | |
5 | import java.util.Arrays; | |
6 | import java.util.stream.Collectors; | |
7 | ||
8 | /** | |
9 | * Helper functions for manipulating stack traces. | |
10 | */ | |
11 | public final class StacktraceUtils { | |
12 | ||
13 | private StacktraceUtils() { | |
14 | // cannot construct | |
15 | } | |
16 | ||
17 | /** | |
18 | * grabs the stacktrace out of a {@link Throwable} as a string | |
19 | */ | |
20 | public static String stackTraceToString(Throwable ex) { | |
21 | StringWriter sw = new StringWriter(); | |
22 | PrintWriter pw = new PrintWriter(sw); | |
23 |
1
1. stackTraceToString : removed call to java/lang/Throwable::printStackTrace → KILLED |
ex.printStackTrace(pw); |
24 |
1
1. stackTraceToString : replaced return value with "" for com/renomad/minum/utils/StacktraceUtils::stackTraceToString → KILLED |
return sw.toString(); |
25 | } | |
26 | ||
27 | /** | |
28 | * Converts an array of {@link StackTraceElement} to a single string, joining | |
29 | * them with a semicolon as delimiter. This way our stacktrace becomes a single line. | |
30 | */ | |
31 | public static String stackTraceToString(StackTraceElement[] elements) { | |
32 |
1
1. stackTraceToString : replaced return value with "" for com/renomad/minum/utils/StacktraceUtils::stackTraceToString → KILLED |
return Arrays.stream(elements).map(StackTraceElement::toString).collect(Collectors.joining(";")); |
33 | } | |
34 | ||
35 | } | |
Mutations | ||
23 |
1.1 |
|
24 |
1.1 |
|
32 |
1.1 |