Source:
protected static <ReturnType> ReturnType dispatchWithExceptionHandling(@Nullable final Account account, final String pluginName, final Callable<PluginDispatcherReturnType<ReturnType>> callable, PluginDispatcher<ReturnType> pluginFormDispatcher) throws PaymentApiException { final UUID accountId = account != null ? account.getId() : null; final String accountExternalKey = account != null ? account.getExternalKey() : ""; final RequestData requestData = Request.getPerThreadRequestData(); final String requestId; if (requestData != null) { requestId = requestData.getRequestId(); } else { requestId = "notAvailabeRequestId"; } try { log.debug("Calling plugin with requestId {}", pluginName, requestId); ReturnType result = pluginFormDispatcher.dispatchWithTimeout(callable); log.debug("Successful call of plugin for account with result and requestId {}", pluginName, account.getExternalKey(), result, requestId); return result; } catch (final TimeoutException e) { final String errorMessage = String.format("TimeoutException during the execution of plugin %s with requestId %s ", pluginName, requestId); log.error(errorMessage, e); throw new PaymentApiException(ErrorCode.PAYMENT_PLUGIN_TIMEOUT, accountId, errorMessage); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); final String errorMessage = String.format("InterruptedException during the execution of plugin %s with requestId %s ", pluginName, requestId); log.error(errorMessage, e); throw new PaymentApiException(ErrorCode.PAYMENT_INTERNAL_ERROR, Objects.firstNonNull(e.getMessage(), errorMessage)); } catch (final ExecutionException e) { if (e.getCause() instanceof PaymentApiException) { throw (PaymentApiException) e.getCause(); } else if (e.getCause() instanceof LockFailedException) { final String format = String.format("Failed to lock account %s", accountExternalKey); log.error(String.format(format), e); throw new PaymentApiException(ErrorCode.PAYMENT_INTERNAL_ERROR, format); } else { throw new PaymentApiException(e, ErrorCode.PAYMENT_INTERNAL_ERROR, Objects.firstNonNull(e.getMessage(), "")); } } }

Target:
protected static <ReturnType> ReturnType dispatchWithExceptionHandling(@Nullable final Account account, final String pluginName, final Callable<PluginDispatcherReturnType<ReturnType>> callable, PluginDispatcher<ReturnType> pluginFormDispatcher) throws PaymentApiException { final UUID accountId = account != null ? account.getId() : null; final String accountExternalKey = account != null ? account.getExternalKey() : ""; try { log.debug("Calling plugin {}", pluginName); ReturnType result = pluginFormDispatcher.dispatchWithTimeout(callable); log.debug("Successful call of plugin for account with result {}", pluginName, accountExternalKey, result); return result; } catch (final TimeoutException e) { final String errorMessage = String.format("TimeoutException during the execution of plugin %s", pluginName); log.warn(errorMessage, e); throw new PaymentApiException(ErrorCode.PAYMENT_PLUGIN_TIMEOUT, accountId, errorMessage); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); final String errorMessage = String.format("InterruptedException during the execution of plugin %s", pluginName); log.warn(errorMessage, e); throw new PaymentApiException(ErrorCode.PAYMENT_INTERNAL_ERROR, Objects.firstNonNull(e.getMessage(), errorMessage)); } catch (final ExecutionException e) { if (e.getCause() instanceof PaymentApiException) { throw (PaymentApiException) e.getCause(); } else if (e.getCause() instanceof LockFailedException) { final String format = String.format("Failed to lock account %s", accountExternalKey); log.error(String.format(format), e); throw new PaymentApiException(ErrorCode.PAYMENT_INTERNAL_ERROR, format); } else { throw new PaymentApiException(e, ErrorCode.PAYMENT_INTERNAL_ERROR, Objects.firstNonNull(e.getMessage(), "")); } } }