KieContainerInstance kci = (KieContainerInstance) context.removeContainer(containerId);
if (kci != null) {
synchronized (kci) {
kci.setStatus(KieContainerStatus.DISPOSING); // just in case
if (kci.getKieContainer() != null) {
InternalKieContainer kieContainer = kci.getKieContainer();
kci.setKieContainer(null); // helps reduce concurrent access issues
try {
// this may fail, but we already removed the container from the registry
kieContainer.dispose();
} catch (Exception e) {
logger.warn("Container '" + containerId + "' disposed, but an unexpected exception was raised", e);
return new ServiceResponse<Void>(ServiceResponse.ResponseType.SUCCESS, "Container " + containerId +
" disposed, but exception was raised: " + e.getClass().getName() + ": " + e.getMessage());
}