From addfbeba60389da16a08078de5121251a15ecbb9 Mon Sep 17 00:00:00 2001 From: Jonathan Gamba Date: Tue, 30 Jan 2024 19:25:22 -0600 Subject: [PATCH] #26633 Handle received exceptions when getting site response The commit modifies the logic to handle the processing of responses when invoking the verifyAndReturnSiteAfterCompletion method for site pushing. It now makes use of Java's CompletableFuture.exceptionally method, which allows us to handle exceptions that occur in the previous stages of the pipeline. This change also included a minor adjustment to clarify the calculation for ending time in the Runnable task. --- .../com/dotcms/api/client/push/site/SitePushHandler.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/dotcms-cli/cli/src/main/java/com/dotcms/api/client/push/site/SitePushHandler.java b/tools/dotcms-cli/cli/src/main/java/com/dotcms/api/client/push/site/SitePushHandler.java index 30f24fe9e592..87a79fb9aefe 100644 --- a/tools/dotcms-cli/cli/src/main/java/com/dotcms/api/client/push/site/SitePushHandler.java +++ b/tools/dotcms-cli/cli/src/main/java/com/dotcms/api/client/push/site/SitePushHandler.java @@ -293,11 +293,12 @@ private SiteView verifyAndReturnSiteAfterCompletion(final String operation, final String siteName, final boolean isSiteLive, final boolean isArchived) { - final var siteViewResponse = verifyAndReturnSiteAfterCompletion( + var siteViewFuture = verifyAndReturnSiteAfterCompletion( siteName, isSiteLive, isArchived - ).join(); + ); + final var siteViewResponse = siteViewFuture.exceptionally(ex -> null).join(); if (siteViewResponse == null) { logger.error( @@ -334,7 +335,7 @@ private CompletableFuture verifyAndReturnSiteAfterCompletion( Runnable task = new Runnable() { final long start = System.currentTimeMillis(); - final long end = start + 15 * 1000; + final long end = start + (15 * 1000); @Override public void run() {