Skip to content

Commit 51ac9db

Browse files
authored
Merge pull request #25 from utPLSQL/bugfix/close_reporters_on_error
Close reporters if any unexpected errors occurred while running tests
2 parents f930370 + 817068e commit 51ac9db

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/org/utplsql/api/TestRunner.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ public void run(Connection conn) throws SomeTestsFailedException, SQLException {
171171
if (e.getErrorCode() == SomeTestsFailedException.ERROR_CODE) {
172172
throw new SomeTestsFailedException(e.getMessage(), e);
173173
} else {
174+
// If the execution failed by unexpected reasons finishes all reporters,
175+
// this way the users don't need to care about reporters' sessions hanging.
176+
try (CallableStatement closeBufferStmt = conn.prepareCall("BEGIN ut_output_buffer.close(?); END;")) {
177+
closeBufferStmt.setArray(1, oraConn.createOracleArray(CustomTypes.UT_REPORTERS, this.reporterList.toArray()));
178+
closeBufferStmt.execute();
179+
} catch (SQLException ignored) {}
180+
174181
throw e;
175182
}
176183
} finally {

0 commit comments

Comments
 (0)