Skip to content

Commit

Permalink
Merge pull request #15571 from cdapio/CDAP-20968
Browse files Browse the repository at this point in the history
[CDAP-20968] Add exception information when connection macro evaluation fails due to timeout
  • Loading branch information
itsankit-google authored Mar 25, 2024
2 parents ce57be5 + d131ca3 commit 7195e0b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ public Map<String, String> evaluateMap(String macroFunction, String... args)
long delay = RETRY_BASE_DELAY_MILLIS;
double minMultiplier = RETRY_DELAY_MULTIPLIER - RETRY_DELAY_MULTIPLIER * RETRY_RANDOMIZE_FACTOR;
double maxMultiplier = RETRY_DELAY_MULTIPLIER + RETRY_DELAY_MULTIPLIER * RETRY_RANDOMIZE_FACTOR;
Exception ex = null;
Stopwatch stopWatch = new Stopwatch().start();
try {
while (stopWatch.elapsedTime(TimeUnit.MILLISECONDS) < TIMEOUT_MILLIS) {
try {
return evaluateMacroMap(macroFunction, args);
} catch (RetryableException e) {
ex = e;
TimeUnit.MILLISECONDS.sleep(delay);
delay = (long) (delay * (minMultiplier + Math.random() * (maxMultiplier - minMultiplier
+ 1)));
Expand All @@ -158,7 +160,8 @@ public Map<String, String> evaluateMap(String macroFunction, String... args)
}
throw new IllegalStateException(
"Timed out when trying to evaluate the value for '" + functionName
+ "' with args " + Arrays.asList(args));
+ "' with args " + Arrays.asList(args) + " with exception: ",
ex == null ? ex : ex.getCause());
}

protected String validateAndRetrieveContent(String serviceName,
Expand Down

0 comments on commit 7195e0b

Please sign in to comment.