ServiceUtils.handleExceptions(null, null); ServiceUtils.handleExceptions(null, () -> flag.set(1)); assertEquals(1, flag.get()); ServiceUtils.handleExceptions(null, () -> { throw new RuntimeException("error"); }); ServiceUtils.handleExceptions(op4, () -> flag.set(0)); assertEquals(0, flag.get()); ServiceUtils.handleExceptions(op5, () -> { flag.set(0); op5.complete(); ServiceUtils.handleExceptions(op6, () -> { flag.set(0); throw new RuntimeException("error");
/** * start processing the request - first fetch the ContainerState */ private void getContainerStateAndProcess(Operation op, String id) { final String containerLink = UriUtils.buildUriPath(ContainerFactoryService.SELF_LINK, id); sendRequest(Operation .createGet(UriUtils.buildUri(getHost(), containerLink)) .setCompletion((o, ex) -> { if (ex != null) { logWarning("Container '%s' not found", containerLink); op.fail(Operation.STATUS_CODE_NOT_FOUND); return; } ServiceUtils.handleExceptions(op, () -> { ContainerState containerState = o.getBody(ContainerState.class); processInspect(containerState, () -> processStatsRequest(op, containerState)); }); })); }