Source:
public void run() { try (OpenShiftClient client = clouldClientHelper.get()) { logger.info("Watching ConfigMap in namespace {}", client.getNamespace()); try (Watch watchable = client.configMaps().watch(new Watcher<ConfigMap>() { @Override public void eventReceived(Action action, ConfigMap kieServerState) { logger.info("Event - Action: {}, on ConfigMap ", action, kieServerState.getMetadata().getName()); DeploymentConfig dc = client.deploymentConfigs().withName(kieServerId).get(); if (kieServerId.equals(kieServerState.getMetadata().getName()) && action.equals(Action.MODIFIED) && "True".equals(dc.getStatus().getConditions().get(0).getStatus()) && triggerRollout(client, kieServerId)) { ObjectMeta md = dc.getSpec().getTemplate().getMetadata(); Map<String, String> ann = md.getAnnotations() == null ? new HashMap<>() : md.getAnnotations(); md.setAnnotations(ann); ann.put(ROLLOUT_TRIGGER_TIMESTAMP, ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT)); client.deploymentConfigs().createOrReplace(dc); logger.info("Update DeploymentConfig: {}", md.getName()); } else { logger.info("Event - Ignored"); } } @Override public void onClose(KubernetesClientException cause) { logger.info("Watcher closed."); if (cause != null) { logger.info(cause.getMessage()); } } })) { logger.info("Watcher created."); Runtime.getRuntime().addShutdownHook(new Thread(() -> { synchronized (this) { isWatchRunning = false; notifyAll(); logger.info("ShutdownHook sent notifyAll."); } })); synchronized (this) { while (isWatchRunning && !Thread.currentThread().isInterrupted()) { logger.info("WatchRunner thread starts."); try { wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.error("WatchRunner thread being interrupted", e); } logger.info("WatchRunner thread being notified."); } logger.info("WatchRunner thread exits."); } } } catch (KubernetesClientException e) { logger.error("Failed", e); } }

Target:
public void run() { try (OpenShiftClient client = clouldClientHelper.get()) { logger.info("Watching ConfigMap in namespace: [{}]", client.getNamespace()); try (Watch watchable = client.configMaps().watch(new Watcher<ConfigMap>() { @Override public void eventReceived(Action action, ConfigMap kieServerState) { logger.debug("Event - Action: {}, on ConfigMap ", action, kieServerState.getMetadata().getName()); DeploymentConfig dc = client.deploymentConfigs().withName(kieServerId).get(); if (kieServerId.equals(kieServerState.getMetadata().getName()) && action.equals(Action.MODIFIED) && isRolloutRequired(client, kieServerId, isDCStable(dc))) { ObjectMeta md = dc.getSpec().getTemplate().getMetadata(); Map<String, String> ann = md.getAnnotations() == null ? new HashMap<>() : md.getAnnotations(); md.setAnnotations(ann); ann.put(ROLLOUT_TRIGGER_TIMESTAMP, ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT)); client.deploymentConfigs().createOrReplace(dc); logger.info("Updated DeploymentConfig: {}", md.getName()); } else { logger.debug("Event - Ignored"); } } @Override public void onClose(KubernetesClientException cause) { logger.info("Watcher closed."); if (cause != null) { logger.info(cause.getMessage()); } } })) { logger.info("Watcher created"); Runtime.getRuntime().addShutdownHook(new Thread(() -> { synchronized (this) { isWatchRunning = false; notifyAll(); logger.info("ShutdownHook sent notifyAll"); } })); synchronized (this) { while (isWatchRunning && !Thread.currentThread().isInterrupted()) { logger.info("WatchRunner thread run"); try { wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.error("WatchRunner thread being interrupted", e); } logger.info("WatchRunner thread being notified"); } logger.info("WatchRunner thread exits"); } } } catch (KubernetesClientException kce) { logger.error("WatchRunner thread failed", kce); } }