This is an automated email from the ASF dual-hosted git repository.
RocMarshal pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new c89d7fcb084 [hotfix][test-utils-junit] Keep
TestLoggerExtension#exceptionToString and delete TestLogger#exceptionToString
to reduce code redundancy.
c89d7fcb084 is described below
commit c89d7fcb084c363ad338c8469425c7ca6ddea0b2
Author: Yuepeng Pan <[email protected]>
AuthorDate: Fri Oct 16 23:05:41 2026 +0800
[hotfix][test-utils-junit] Keep TestLoggerExtension#exceptionToString and
delete TestLogger#exceptionToString to reduce code redundancy.
---
.../main/java/org/apache/flink/util/TestLogger.java | 19 +------------------
.../org/apache/flink/util/TestLoggerExtension.java | 8 +++-----
2 files changed, 4 insertions(+), 23 deletions(-)
diff --git
a/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/TestLogger.java
b/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/TestLogger.java
index c72e436eb46..841a400c8b2 100644
---
a/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/TestLogger.java
+++
b/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/TestLogger.java
@@ -25,8 +25,7 @@ import org.junit.runner.Description;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.PrintWriter;
-import java.io.StringWriter;
+import static org.apache.flink.util.TestLoggerExtension.exceptionToString;
/**
* Adds automatic test name logging. Every test which wants to log which test
is currently executed
@@ -73,20 +72,4 @@ public class TestLogger {
};
@Rule public final TestRule nameProvider = new TestNameProvider();
-
- private static String exceptionToString(Throwable t) {
- if (t == null) {
- return "(null)";
- }
-
- try {
- StringWriter stm = new StringWriter();
- PrintWriter wrt = new PrintWriter(stm);
- t.printStackTrace(wrt);
- wrt.close();
- return stm.toString();
- } catch (Throwable ignored) {
- return t.getClass().getName() + " (error while printing stack
trace)";
- }
- }
}
diff --git
a/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/TestLoggerExtension.java
b/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/TestLoggerExtension.java
index 82595b5a9fb..c6cfcf183a3 100644
---
a/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/TestLoggerExtension.java
+++
b/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/TestLoggerExtension.java
@@ -65,16 +65,14 @@ public class TestLoggerExtension implements TestWatcher,
BeforeEachCallback {
exceptionToString(cause));
}
- private static String exceptionToString(Throwable t) {
+ static String exceptionToString(Throwable t) {
if (t == null) {
return "(null)";
}
- try {
- StringWriter stm = new StringWriter();
- PrintWriter wrt = new PrintWriter(stm);
+ try (StringWriter stm = new StringWriter();
+ PrintWriter wrt = new PrintWriter(stm)) {
t.printStackTrace(wrt);
- wrt.close();
return stm.toString();
} catch (Throwable ignored) {
return t.getClass().getName() + " (error while printing stack
trace)";