From 817068ea5c56676563e70885bb8eb12a34f44eb6 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Sun, 29 Oct 2017 10:51:21 +0000 Subject: [PATCH] Close reporters if any unexpected errors occurred while running tests --- src/main/java/org/utplsql/api/TestRunner.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/utplsql/api/TestRunner.java b/src/main/java/org/utplsql/api/TestRunner.java index 549caa4..344223d 100644 --- a/src/main/java/org/utplsql/api/TestRunner.java +++ b/src/main/java/org/utplsql/api/TestRunner.java @@ -171,6 +171,13 @@ public void run(Connection conn) throws SomeTestsFailedException, SQLException { if (e.getErrorCode() == SomeTestsFailedException.ERROR_CODE) { throw new SomeTestsFailedException(e.getMessage(), e); } else { + // If the execution failed by unexpected reasons finishes all reporters, + // this way the users don't need to care about reporters' sessions hanging. + try (CallableStatement closeBufferStmt = conn.prepareCall("BEGIN ut_output_buffer.close(?); END;")) { + closeBufferStmt.setArray(1, oraConn.createOracleArray(CustomTypes.UT_REPORTERS, this.reporterList.toArray())); + closeBufferStmt.execute(); + } catch (SQLException ignored) {} + throw e; } } finally {