use of org.jboss.pnc.spi.environment.DestroyableEnvironment in project pnc by project-ncl.
the class DefaultBuildExecutor method stopRunningEnvironment.
/**
* Tries to stop running environment if the exception contains information about running environment
*
* @param ex Exception in build process (To stop the environment it has to be instance of BuildProcessException)
*/
private void stopRunningEnvironment(Throwable ex) {
DestroyableEnvironment destroyableEnvironment = null;
if (ex instanceof BuildProcessException) {
BuildProcessException bpEx = (BuildProcessException) ex;
destroyableEnvironment = bpEx.getDestroyableEnvironment();
} else if (ex.getCause() instanceof BuildProcessException) {
BuildProcessException bpEx = (BuildProcessException) ex.getCause();
destroyableEnvironment = bpEx.getDestroyableEnvironment();
} else {
// It shouldn't never happen - Throwable should be caught in all steps of build chain
// and BuildProcessException should be thrown instead of that
log.warn("Possible leak of a running environment! Build process ended with exception, " + "but the exception didn't contain information about running environment.", ex);
}
try {
if (destroyableEnvironment != null) {
destroyableEnvironment.destroyEnvironment();
}
} catch (Throwable envE) {
log.warn("Running environment" + destroyableEnvironment + " couldn't be destroyed!", envE);
}
}
Aggregations