Skip to content

Commit

Permalink
[WFCORE-765] ServerDomainProcessShutdownHandler shouldn't fail if shu…
Browse files Browse the repository at this point in the history
…tdown is already underway
  • Loading branch information
bstansberry committed Jun 17, 2015
1 parent 4c5dd34 commit 293f755
Showing 1 changed file with 12 additions and 6 deletions.
Expand Up @@ -24,6 +24,7 @@


import java.util.EnumSet;

import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
Expand Down Expand Up @@ -99,12 +100,17 @@ public void handleResult(OperationContext.ResultAction resultAction, OperationCo
//to stop new requests being accepted as it is shutting down
final ServiceRegistry registry = context.getServiceRegistry(false);

final ServiceController<GracefulShutdownService> gracefulController = (ServiceController<GracefulShutdownService>) registry.getRequiredService(GracefulShutdownService.SERVICE_NAME);
gracefulController.getValue().startGracefulShutdown();

final ServiceController<SuspendController> suspendControllerServiceController = (ServiceController<SuspendController>) registry.getRequiredService(SuspendController.SERVICE_NAME);
final SuspendController suspendController = suspendControllerServiceController.getValue();
suspendController.suspend(timeout > 0 ? timeout * 1000 : timeout);
// WFCORE-765 if either of the services we use are not present, graceful shutdown
// is not possible, but don't fail. The services may be missing if the server
// is already shutting down due to receiving a SIGINT
final ServiceController<GracefulShutdownService> gracefulController = (ServiceController<GracefulShutdownService>) registry.getService(GracefulShutdownService.SERVICE_NAME);
if (gracefulController != null) {
final ServiceController<SuspendController> suspendControllerServiceController = (ServiceController<SuspendController>) registry.getService(SuspendController.SERVICE_NAME);
if (suspendControllerServiceController != null) {
gracefulController.getValue().startGracefulShutdown();
suspendControllerServiceController.getValue().suspend(timeout > 0 ? timeout * 1000 : timeout);
}
}
}
}
});
Expand Down

0 comments on commit 293f755

Please sign in to comment.