Skip to content

Commit

Permalink
Abort with exception on Reporter-timeout
Browse files Browse the repository at this point in the history
Fixes #129
  • Loading branch information
pesse committed Feb 19, 2019
1 parent a4927a7 commit 079e021
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/org/utplsql/cli/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.utplsql.api.reporter.Reporter;
import org.utplsql.api.reporter.ReporterFactory;
import org.utplsql.cli.exception.DatabaseConnectionFailed;
import org.utplsql.cli.exception.ReporterTimeoutException;
import org.utplsql.cli.log.StringBlockFormatter;

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

executorService.shutdown();
executorService.awaitTermination(timeoutInMinutes, TimeUnit.MINUTES);
if ( !executorService.awaitTermination(timeoutInMinutes, TimeUnit.MINUTES) ) {
throw new ReporterTimeoutException(timeoutInMinutes);
}

logger.info("--------------------------------------");
logger.info("All tests done.");

return returnCode[0];
}
catch ( DatabaseNotCompatibleException | UtPLSQLNotInstalledException | DatabaseConnectionFailed e ) {
catch ( DatabaseNotCompatibleException | UtPLSQLNotInstalledException | DatabaseConnectionFailed | ReporterTimeoutException e ) {
System.out.println(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
}
return 1;
return Cli.DEFAULT_ERROR_CODE;
}

private ArrayList<String> getObjectList(String includeObjects) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.utplsql.cli.exception;

public class ReporterTimeoutException extends Exception {

private final int timeOutInMinutes;

public ReporterTimeoutException( int timeoutInMinutes ) {
super("Timeout while waiting for reporters to finish for " + timeoutInMinutes + " minutes");
this.timeOutInMinutes = timeoutInMinutes;
}

public int getTimeOutInMinutes() {
return timeOutInMinutes;
}
}

0 comments on commit 079e021

Please sign in to comment.