diff --git a/server/libs/platform/platform-component/platform-component-api/src/main/java/com/bytechef/platform/component/util/RefreshCredentialsUtils.java b/server/libs/platform/platform-component/platform-component-api/src/main/java/com/bytechef/platform/component/util/RefreshCredentialsUtils.java index 2cd51a27365..07e53efe6e1 100644 --- a/server/libs/platform/platform-component/platform-component-api/src/main/java/com/bytechef/platform/component/util/RefreshCredentialsUtils.java +++ b/server/libs/platform/platform-component/platform-component-api/src/main/java/com/bytechef/platform/component/util/RefreshCredentialsUtils.java @@ -31,7 +31,9 @@ public class RefreshCredentialsUtils { public static boolean matches(List refreshOn, Exception exception) { boolean matches = false; - if (exception instanceof ProviderException providerException && providerException.getStatusCode() != null) { + if (exception instanceof ProviderException providerException + && Objects.nonNull(providerException.getStatusCode())) { + matches = matches( providerException.getStatusCode(), CollectionUtils.map( @@ -39,25 +41,23 @@ public static boolean matches(List refreshOn, Exception exception) { item -> (Integer) item)); } - if (!matches) { - if (Objects.isNull(exception.getMessage())) { - return false; - } + if (matches) { + return matches; + } - Throwable curException = exception; + Throwable throwable = exception; - do { - matches = matches( - curException.getMessage(), - CollectionUtils.map( - CollectionUtils.filter(refreshOn, item -> item instanceof String), item -> (String) item)); + while (Objects.nonNull(throwable) && Objects.nonNull(throwable.getMessage())) { + matches = matches( + throwable.getMessage(), + CollectionUtils.map( + CollectionUtils.filter(refreshOn, item -> item instanceof String), item -> (String) item)); - if (matches) { - break; - } + if (matches) { + return matches; + } - curException = curException.getCause(); - } while (curException != null); + throwable = throwable.getCause(); } return matches;