From 7f27e56a3b3af400925a09cb3ca100d6a40d001f Mon Sep 17 00:00:00 2001 From: Vincent Massol Date: Wed, 24 Aug 2022 13:49:59 +0200 Subject: [PATCH] [Misc] Add debug information to better understand the timeout cause --- .../export/pdf/internal/chrome/ChromeManager.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/main/java/org/xwiki/export/pdf/internal/chrome/ChromeManager.java b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/main/java/org/xwiki/export/pdf/internal/chrome/ChromeManager.java index e9be7ce8ef0e..de8673e70537 100644 --- a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/main/java/org/xwiki/export/pdf/internal/chrome/ChromeManager.java +++ b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/main/java/org/xwiki/export/pdf/internal/chrome/ChromeManager.java @@ -143,13 +143,15 @@ private void waitForChromeService(int timeoutSeconds) throws TimeoutException int timeoutMillis = timeoutSeconds * 1000; long start = System.currentTimeMillis(); + Exception exception = null; while (System.currentTimeMillis() - start < timeoutMillis) { try { this.chromeService.getVersion(); return; } catch (Exception e) { - this.logger.debug("Chrome remote debugging not available. Retrying in 2s."); + exception = e; + this.logger.debug("Chrome remote debugging not available. Retrying in 2s.", e); try { Thread.sleep(2000); } catch (InterruptedException ie) { @@ -162,8 +164,12 @@ private void waitForChromeService(int timeoutSeconds) throws TimeoutException } long waitTime = (System.currentTimeMillis() - start) / 1000; - throw new TimeoutException(String - .format("Timeout waiting for Chrome remote debugging to become available. Waited [%s] seconds.", waitTime)); + String message = String.format("Timeout waiting for Chrome remote debugging to become available. Waited [%s] " + + "seconds", waitTime); + if (exception != null) { + message = String.format("%s. Root cause: [%s]", ExceptionUtils.getRootCauseMessage(exception)); + } + throw new TimeoutException(message); } /**