private <T extends TaobaoResponse> T _execute( TaobaoRequest<T> request, TaobaoParser<T> parser, String authToken, String version) throws AlipayApiException { Map<String, Object> rt = doPost(request, authToken, version); if (rt == null) { return null; } T tRsp = null; try { tRsp = parser.parse((String) rt.get("rsp")); tRsp.setBody((String) rt.get("rsp")); } catch (RuntimeException e) { TaobaoLogger.logBizError((String) rt.get("rsp")); throw e; } catch (ApiException e) { TaobaoLogger.logBizError((String) rt.get("rsp")); throw new AlipayApiException(e); } tRsp.setParams((TaobaoHashMap) rt.get("textParams")); if (!tRsp.isSuccess()) { TaobaoLogger.logErrorScene(rt, tRsp, ""); } return tRsp; }
public T call() throws Exception { final T result1 = step1.call(); if (result1.isSuccess() && !Thread.currentThread().isInterrupted()) { return step2.call(); } else { return result1; } }
public <T extends TaobaoResponse> T execute(TaobaoRequest<T> request, String session) throws ApiException { T rsp = null; ApiException exp = null; for (int i = 0; i <= maxRetryCount; i++) { if (i > 0) { if ((rsp != null && ((rsp.getSubCode() != null && rsp.getSubCode().startsWith("isp.")) || (retryErrorCodes != null && retryErrorCodes.contains(rsp.getSubCode())))) || exp != null) { sleepWithoutInterrupt(retryWaitTime); log.warn(buildRetryLog(request.getApiMethodName(), request.getTextParams(), i)); } else { break; } } try { rsp = super.execute(request, session); if (rsp.isSuccess()) { return rsp; } else { if (i == maxRetryCount && throwIfOverMaxRetry) { throw RETRY_FAIL; } } } catch (ApiException e) { if (exp == null) { exp = e; } } } if (exp != null) { throw exp; } else { return rsp; } }