Details
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/ExceptionMapperBase.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/ExceptionMapperBase.java
index 28fde6e..469153a 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/ExceptionMapperBase.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/ExceptionMapperBase.java
@@ -175,6 +175,18 @@ public abstract class ExceptionMapperBase {
.build();
}
+ protected Response buildPluginTimeoutResponse(final Exception e, final UriInfo uriInfo) {
+ return buildPluginTimeoutResponse(exceptionToString(e), uriInfo);
+ }
+
+ private Response buildPluginTimeoutResponse(final String error, final UriInfo uriInfo) {
+ return Response.status(Status.ACCEPTED)
+ .entity(error)
+ .type(MediaType.TEXT_PLAIN_TYPE)
+ .build();
+ }
+
+
private String exceptionToString(final Exception e) {
try {
return mapper.writeValueAsString(new BillingExceptionJson(e));
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/PaymentApiExceptionMapper.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/PaymentApiExceptionMapper.java
index 9fb84ad..c89369d 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/PaymentApiExceptionMapper.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/PaymentApiExceptionMapper.java
@@ -63,7 +63,7 @@ public class PaymentApiExceptionMapper extends ExceptionMapperBase implements Ex
} else if (exception.getCode() == ErrorCode.PAYMENT_NULL_INVOICE.getCode()) {
return buildBadRequestResponse(exception, uriInfo);
} else if (exception.getCode() == ErrorCode.PAYMENT_PLUGIN_TIMEOUT.getCode()) {
- return buildInternalErrorResponse(exception, uriInfo);
+ return buildPluginTimeoutResponse(exception, uriInfo);
} else if (exception.getCode() == ErrorCode.PAYMENT_REFRESH_PAYMENT_METHOD.getCode()) {
return buildInternalErrorResponse(exception, uriInfo);
} else if (exception.getCode() == ErrorCode.PAYMENT_UPD_PAYMENT_METHOD.getCode()) {
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentAutomatonRunner.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentAutomatonRunner.java
index eeeaba6..ce88338 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentAutomatonRunner.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentAutomatonRunner.java
@@ -21,6 +21,7 @@ import java.math.BigDecimal;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import javax.annotation.Nullable;
import javax.inject.Inject;
@@ -188,6 +189,8 @@ public class PaymentAutomatonRunner {
throw new PaymentApiException(e, ErrorCode.PAYMENT_INTERNAL_ERROR, Objects.firstNonNull(e.getMessage(), ""));
} else if (e.getCause() instanceof PaymentApiException) {
throw (PaymentApiException) e.getCause();
+ } else if (e.getCause() instanceof TimeoutException) {
+ throw new PaymentApiException(e.getCause(), ErrorCode.PAYMENT_PLUGIN_TIMEOUT, Objects.firstNonNull(e.getMessage(), ""));
} else {
throw new PaymentApiException(e.getCause(), ErrorCode.PAYMENT_INTERNAL_ERROR, Objects.firstNonNull(e.getMessage(), ""));
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentOperation.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentOperation.java
index e2b2a65..518042c 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentOperation.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentOperation.java
@@ -83,7 +83,7 @@ public abstract class PaymentOperation extends OperationCallbackBase<PaymentTran
return new OperationException(realException, OperationResult.FAILURE);
} else if (e.getCause() instanceof LockFailedException) {
final String format = String.format("Failed to lock account %s", paymentStateContext.getAccount().getExternalKey());
- logger.error(String.format(format), e);
+ logger.error(String.format(format));
return new OperationException(realException, OperationResult.FAILURE);
} else /* if (e instanceof RuntimeException) */ {
logger.warn("Plugin call threw an exception for account {}", paymentStateContext.getAccount().getExternalKey(), e);
@@ -93,13 +93,13 @@ public abstract class PaymentOperation extends OperationCallbackBase<PaymentTran
@Override
protected OperationException wrapTimeoutException(final PaymentStateContext paymentStateContext, final TimeoutException e) {
- logger.error("Plugin call TIMEOUT for account {}: {}", paymentStateContext.getAccount().getExternalKey(), e.getMessage());
+ logger.error("Plugin call TIMEOUT for account {}", paymentStateContext.getAccount().getExternalKey());
return new OperationException(e, OperationResult.EXCEPTION);
}
@Override
protected OperationException wrapInterruptedException(final PaymentStateContext paymentStateContext, final InterruptedException e) {
- logger.error("Plugin call was interrupted for account {}: {}", paymentStateContext.getAccount().getExternalKey(), e.getMessage());
+ logger.error("Plugin call was interrupted for account {}", paymentStateContext.getAccount().getExternalKey());
return new OperationException(e, OperationResult.EXCEPTION);
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java
index 0e44d5c..b7f6310 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java
@@ -157,7 +157,7 @@ public abstract class RetryOperationCallback extends OperationCallbackBase<Payme
return (OperationException) e.getCause();
} else if (e.getCause() instanceof LockFailedException) {
final String format = String.format("Failed to lock account %s", paymentStateContext.getAccount().getExternalKey());
- logger.error(String.format(format), e);
+ logger.error(String.format(format));
return new OperationException(e, getOperationResultOnException(paymentStateContext));
} else /* most probably RuntimeException */ {
logger.warn("RetryOperationCallback failed for account {}", paymentStateContext.getAccount().getExternalKey(), e);
@@ -167,13 +167,13 @@ public abstract class RetryOperationCallback extends OperationCallbackBase<Payme
@Override
protected OperationException wrapTimeoutException(final PaymentStateContext paymentStateContext, final TimeoutException e) {
- logger.error("RetryOperationCallback call TIMEOUT for account {}: {}", paymentStateContext.getAccount().getExternalKey(), e.getMessage());
+ logger.error("RetryOperationCallback call TIMEOUT for account {}", paymentStateContext.getAccount().getExternalKey());
return new OperationException(e, getOperationResultOnException(paymentStateContext));
}
@Override
protected OperationException wrapInterruptedException(final PaymentStateContext paymentStateContext, final InterruptedException e) {
- logger.error("RetryOperationCallback call was interrupted for account {}: {}", paymentStateContext.getAccount().getExternalKey(), e.getMessage());
+ logger.error("RetryOperationCallback call was interrupted for account {}", paymentStateContext.getAccount().getExternalKey());
return new OperationException(e, getOperationResultOnException(paymentStateContext));
}