Skip to content

Commit 079e021

Browse files
committed
Abort with exception on Reporter-timeout
Fixes #129
1 parent a4927a7 commit 079e021

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/main/java/org/utplsql/cli/RunCommand.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.utplsql.api.reporter.Reporter;
1414
import org.utplsql.api.reporter.ReporterFactory;
1515
import org.utplsql.cli.exception.DatabaseConnectionFailed;
16+
import org.utplsql.cli.exception.ReporterTimeoutException;
1617
import org.utplsql.cli.log.StringBlockFormatter;
1718

1819
import javax.sql.DataSource;
@@ -201,19 +202,21 @@ public int run() {
201202
getReporterManager().startReporterGatherers(executorService, dataSource, returnCode);
202203

203204
executorService.shutdown();
204-
executorService.awaitTermination(timeoutInMinutes, TimeUnit.MINUTES);
205+
if ( !executorService.awaitTermination(timeoutInMinutes, TimeUnit.MINUTES) ) {
206+
throw new ReporterTimeoutException(timeoutInMinutes);
207+
}
205208

206209
logger.info("--------------------------------------");
207210
logger.info("All tests done.");
208211

209212
return returnCode[0];
210213
}
211-
catch ( DatabaseNotCompatibleException | UtPLSQLNotInstalledException | DatabaseConnectionFailed e ) {
214+
catch ( DatabaseNotCompatibleException | UtPLSQLNotInstalledException | DatabaseConnectionFailed | ReporterTimeoutException e ) {
212215
System.out.println(e.getMessage());
213216
} catch (Exception e) {
214217
e.printStackTrace();
215218
}
216-
return 1;
219+
return Cli.DEFAULT_ERROR_CODE;
217220
}
218221

219222
private ArrayList<String> getObjectList(String includeObjects) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.utplsql.cli.exception;
2+
3+
public class ReporterTimeoutException extends Exception {
4+
5+
private final int timeOutInMinutes;
6+
7+
public ReporterTimeoutException( int timeoutInMinutes ) {
8+
super("Timeout while waiting for reporters to finish for " + timeoutInMinutes + " minutes");
9+
this.timeOutInMinutes = timeoutInMinutes;
10+
}
11+
12+
public int getTimeOutInMinutes() {
13+
return timeOutInMinutes;
14+
}
15+
}

0 commit comments

Comments
 (0)