Skip to content

Commit abd49d7

Browse files
committed
minor refactoring
1 parent 5a0f432 commit abd49d7

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

java/src/main/java/com/cybersource/ws/client/Client.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,15 @@ public static Map<String, String> runTransaction(
101101

102102
setVersionInformation(request);
103103

104+
logger = new LoggerWrapper(_logger, prepare, logTranStart, mc);
105+
104106
if (mc.getUseHttpClientWithConnectionPool()){
105107
String mtiField = request.get(MERCHANT_TRANSACTION_IDENTIFIER);
106108
if(StringUtils.isBlank(mtiField)) {
107109
throw new ClientException(HTTP_BAD_REQUEST, MTI_FIELD_ERR_MSG, false, logger);
108110
}
109111
}
110112

111-
112-
logger = new LoggerWrapper(_logger, prepare, logTranStart, mc);
113-
114113
DocumentBuilder builder = Utility.newDocumentBuilder();
115114

116115
Document signedDoc

java/src/main/java/com/cybersource/ws/client/PoolingHttpClientConnection.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,13 @@ public boolean retryRequest(IOException exception, int executionCount, HttpConte
338338

339339
HttpClientContext httpClientContext = HttpClientContext.adapt(httpContext);
340340
if (!httpClientContext.isRequestSent()) {
341-
retryAfter(retryWaitInterval, executionCount, logger);
341+
retryAfter(retryWaitInterval, executionCount, "request_not_sent");
342342
return true;
343343
}
344344

345345
if(mc.retryIfMTIFieldExistEnabled()){
346346
if (exception instanceof NoHttpResponseException) {
347-
retryAfter(retryWaitInterval, executionCount, logger);
347+
retryAfter(retryWaitInterval, executionCount, "NoHttpResponseException");
348348
return true;
349349
}
350350
if(exception instanceof java.net.SocketException) {
@@ -353,7 +353,7 @@ public boolean retryRequest(IOException exception, int executionCount, HttpConte
353353
errMessage = exception.getLocalizedMessage();
354354
}
355355
if (StringUtils.isNotBlank(errMessage) && ( errMessage.equalsIgnoreCase("Connection reset") || errMessage.contains("Connection reset"))) {
356-
retryAfter(retryWaitInterval, executionCount, logger);
356+
retryAfter(retryWaitInterval, executionCount, "SocketException:Connection reset");
357357
return true;
358358
}
359359
}
@@ -388,10 +388,10 @@ private void setProxy(HttpClientBuilder httpClientBuilder, RequestConfig.Builder
388388
}
389389
}
390390

391-
private void retryAfter(long millis, int executionCount, LoggerWrapper logger) {
391+
private void retryAfter(long millis, int executionCount, String reason) {
392392
try {
393393
Thread.sleep(millis);
394-
logger.log(Logger.LT_INFO, "Retrying Request -- " + logger.getUniqueKey() + " Retry Count -- " + executionCount);
394+
logger.log(Logger.LT_INFO, "Retrying Request due to " + reason +"-- Retry Count -- " + executionCount);
395395
} catch (InterruptedException ex) {
396396
ex.printStackTrace();
397397
}

java/src/main/java/com/cybersource/ws/client/XMLClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,15 @@ public static Document runTransaction(
169169

170170
nsURI = mc.getEffectiveNamespaceURI();
171171

172+
logger = new LoggerWrapper(_logger, prepare, logTranStart, mc);
173+
172174
if (mc.getUseHttpClientWithConnectionPool()){
173175
String mtiField = checkIfMTIFiledExist(request, nsURI);
174176
if(StringUtils.isBlank(mtiField)) {
175177
throw new ClientException(HTTP_BAD_REQUEST, MTI_FIELD_ERR_MSG, false, logger);
176178
}
177179
}
178180

179-
logger = new LoggerWrapper(_logger, prepare, logTranStart, mc);
180-
181181
setVersionInformation(request, nsURI, mc.retryIfMTIFieldExistEnabled());
182182

183183
DocumentBuilder builder = Utility.newDocumentBuilder();

0 commit comments

Comments
 (0)