Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Abort with exception on Reporter-timeout
Fixes #129
  • Loading branch information
pesse committed Feb 19, 2019
commit 079e021a747fe3829f868ad08c95a6eef2cc2f1c
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;
}
}