Skip to content

Commit a3610b1

Browse files
committed
review comments
1 parent fc735ee commit a3610b1

11 files changed

Lines changed: 35 additions & 34 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static Map<String, String> runTransaction(
9191
LoggerWrapper logger = null;
9292
Connection con = null;
9393
try {
94-
long requestSentTime = System.currentTimeMillis();
94+
long startTime = System.currentTimeMillis();
9595
boolean isMerchantConfigCacheEnabled = Boolean.parseBoolean(props.getProperty("merchantConfigCacheEnabled", "false"));
9696
if(isMerchantConfigCacheEnabled) {
9797
mc = getInstanceMap(request, props);
@@ -151,7 +151,7 @@ public static Map<String, String> runTransaction(
151151
else{
152152
con = Connection.getInstance(mc, builder, logger);
153153
}
154-
Document wrappedReply = con.post(signedDoc, requestSentTime);
154+
Document wrappedReply = con.post(signedDoc, startTime);
155155
Map<String, String> replyMap = soapUnwrap(wrappedReply, mc, logger);
156156
logger.log(Logger.LT_INFO, "Client, End of runTransaction Call ",false);
157157

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ public static Connection getInstance(
9898
/**
9999
* Abstract method to post request
100100
* @param request
101-
* @param requestSentTime
101+
* @param startTime
102102
* @throws IOException
103103
* @throws TransformerConfigurationException
104104
* @throws TransformerException
105105
* @throws MalformedURLException
106106
* @throws ProtocolException
107107
*/
108-
abstract void postDocument(Document request, long requestSentTime)
108+
abstract void postDocument(Document request, long startTime)
109109
throws IOException, TransformerConfigurationException,
110110
TransformerException, MalformedURLException,
111111
ProtocolException;
@@ -141,10 +141,10 @@ abstract InputStream getResponseErrorStream()
141141
* @throws ClientException
142142
* @throws FaultException
143143
*/
144-
public Document post(Document request, long requestSentTime)
144+
public Document post(Document request, long startTime)
145145
throws ClientException, FaultException {
146146
try {
147-
postDocument(request, requestSentTime);
147+
postDocument(request, startTime);
148148
checkForFault();
149149
return (parseReceivedDocument());
150150
} catch (IOException e) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ public class HttpClientConnection extends Connection {
6464
/**
6565
* Post request by httpclient connection
6666
* @param request
67-
* @param requestSentTime
67+
* @param startTime
6868
* @throws IOException
6969
* @throws TransformerException
7070
*/
7171
/* (non-Javadoc)
7272
* @see com.cybersource.ws.client.Connection#postDocument(org.w3c.dom.Document)
7373
*/
74-
void postDocument(Document request, long requestSentTime)
74+
void postDocument(Document request, long startTime)
7575
throws IOException, TransformerException {
7676

7777
/*
@@ -93,7 +93,7 @@ void postDocument(Document request, long requestSentTime)
9393
postMethod.setRequestEntity(
9494
new StringRequestEntity(requestString, null, "UTF-8"));
9595
postMethod.setRequestHeader(Utility.ORIGIN_TIMESTAMP, String.valueOf(System.currentTimeMillis()));
96-
postMethod.setRequestHeader(Utility.SDK_ELAPSED_TIMESTAMP, String.valueOf(System.currentTimeMillis()-requestSentTime));
96+
postMethod.setRequestHeader(Utility.SDK_ELAPSED_TIMESTAMP, String.valueOf(System.currentTimeMillis()-startTime));
9797
logRequestHeaders();
9898
logger.log(Logger.LT_INFO,
9999
"Sending " + requestString.length() + " bytes to " + serverURL);
@@ -285,7 +285,7 @@ public void logResponseHeaders() {
285285
if(mc.getEnableLog() && postMethod != null) {
286286
Header responseTimeHeader = postMethod.getResponseHeader(RESPONSE_TIME_REPLY);
287287
if (responseTimeHeader != null && StringUtils.isNotBlank(responseTimeHeader.getValue())) {
288-
long resIAT = getResponseIssuedAtTimeInSecs(responseTimeHeader.getValue());
288+
long resIAT = getResponseIssuedAtTime(responseTimeHeader.getValue());
289289
if (resIAT > 0) {
290290
logger.log(Logger.LT_INFO, "responseTransitTimeSec : " + getResponseTransitTime(resIAT));
291291
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ public class JDKHttpURLConnection extends Connection {
6060
/**
6161
* Post request by jdkHttpURL connection
6262
* @param request
63-
* @param requestSentTime
63+
* @param startTime
6464
* @throws IOException
6565
* @throws TransformerException
6666
*/
67-
void postDocument(Document request, long requestSentTime)
67+
void postDocument(Document request, long startTime)
6868
throws IOException,
6969
TransformerException {
7070
//long startTime = System.nanoTime();
7171
String serverURL = mc.getEffectiveServerURL();
7272
URL url = new URL(serverURL);
7373
con = ConnectionHelper.openConnection(url, mc);
7474
con.setRequestProperty(Utility.ORIGIN_TIMESTAMP, String.valueOf(System.currentTimeMillis()));
75-
con.setRequestProperty(Utility.SDK_ELAPSED_TIMESTAMP, String.valueOf(System.currentTimeMillis() - requestSentTime));
75+
con.setRequestProperty(Utility.SDK_ELAPSED_TIMESTAMP, String.valueOf(System.currentTimeMillis() - startTime));
7676
con.setRequestMethod("POST");
7777
con.setDoOutput(true);
7878
ConnectionHelper.setTimeout(con, mc.getTimeout());
@@ -176,7 +176,7 @@ public void logResponseHeaders() {
176176
if (mc.getEnableLog() && con != null) {
177177
String responseTime = con.getHeaderField(RESPONSE_TIME_REPLY);
178178
if (StringUtils.isNotBlank(responseTime)) {
179-
long resIAT = getResponseIssuedAtTimeInSecs(responseTime);
179+
long resIAT = getResponseIssuedAtTime(responseTime);
180180
if (resIAT > 0) {
181181
logger.log(Logger.LT_INFO, "responseTransitTimeSec : " + getResponseTransitTime(resIAT));
182182
}

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class MerchantConfig {
5858
private String logFilename;
5959
private int logMaximumSize;
6060
private boolean useHttpClient;
61+
private boolean merchantConfigCacheEnabled;
6162
private boolean useHttpClientWithConnectionPool;
6263
private int maxConnections;
6364
private int defaultMaxConnectionsPerRoute;
@@ -68,6 +69,15 @@ public class MerchantConfig {
6869
private int evictThreadSleepTimeMs;
6970
private int maxKeepAliveTimeMs;
7071
private int validateAfterInactivityMs;
72+
private boolean staleConnectionCheckEnabled;
73+
private boolean shutdownHookEnabled;
74+
private boolean retryIfMTIFieldExist;
75+
76+
//Retry Pattern
77+
private boolean allowRetry;
78+
private int numberOfRetries = 0;
79+
private long retryInterval = 0;
80+
7181
private int timeout;
7282
private String proxyHost;
7383
private int proxyPort;
@@ -77,21 +87,12 @@ public class MerchantConfig {
7787
private String customHttpClass;
7888
private boolean customHttpClassEnabled;
7989
private boolean certificateCacheEnabled;
80-
private boolean merchantConfigCacheEnabled;
81-
private boolean staleConnectionCheckEnabled;
82-
private boolean shutdownHookEnabled;
83-
private boolean retryIfMTIFieldExist;
8490
// computed values
8591
private String effectiveServerURL;
8692
private String effectiveNamespaceURI;
8793
private String effectivePassword;
8894
private boolean useSignAndEncrypted;
8995

90-
//Retry Pattern
91-
private int numberOfRetries = 0;
92-
private long retryInterval = 0;
93-
private boolean allowRetry;
94-
9596
/**
9697
* Getter method for useSignAndEncrypted
9798
*
@@ -671,8 +672,8 @@ public MerchantConfig(Properties _props, String _merchantID)
671672
retryIfMTIFieldExist = getBooleanProperty(merchantID, "retryIfMTIFieldExist", true);
672673
}
673674

674-
allowRetry = getBooleanProperty(merchantID, "allowRetry", true);
675675
if (useHttpClient || useHttpClientWithConnectionPool) {
676+
allowRetry = getBooleanProperty(merchantID, "allowRetry", true);
676677
if (allowRetry) {
677678
numberOfRetries = getIntegerProperty(merchantID, "numberOfRetries", 3);
678679
if (numberOfRetries > 0)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,18 @@ private void startStaleConnectionMonitorThread(MerchantConfig merchantConfig, Po
146146
* Method to post the request using http pool connection
147147
*
148148
* @param request
149-
* @param requestSentTime
149+
* @param startTime
150150
* @throws IOException
151151
* @throws TransformerException
152152
*/
153153
@Override
154-
void postDocument(Document request, long requestSentTime) throws IOException, TransformerException {
154+
void postDocument(Document request, long startTime) throws IOException, TransformerException {
155155
String serverURL = mc.getEffectiveServerURL();
156156
httpPost = new HttpPost(serverURL);
157157
String requestString = documentToString(request);
158158
StringEntity stringEntity = new StringEntity(requestString, "UTF-8");
159159
httpPost.setEntity(stringEntity);
160-
httpPost.setHeader(Utility.SDK_ELAPSED_TIMESTAMP, String.valueOf(System.currentTimeMillis() - requestSentTime));
160+
httpPost.setHeader(Utility.SDK_ELAPSED_TIMESTAMP, String.valueOf(System.currentTimeMillis() - startTime));
161161
httpPost.setHeader(Utility.ORIGIN_TIMESTAMP, String.valueOf(System.currentTimeMillis()));
162162
logRequestHeaders();
163163
httpContext = HttpClientContext.create();
@@ -293,7 +293,7 @@ public void logResponseHeaders() {
293293
if (mc.getEnableLog() && httpResponse != null) {
294294
Header responseTimeHeader = httpResponse.getFirstHeader(RESPONSE_TIME_REPLY);
295295
if (responseTimeHeader != null && StringUtils.isNotBlank(responseTimeHeader.getValue())) {
296-
long resIAT = getResponseIssuedAtTimeInSecs(responseTimeHeader.getValue());
296+
long resIAT = getResponseIssuedAtTime(responseTimeHeader.getValue());
297297
if (resIAT > 0) {
298298
logger.log(Logger.LT_INFO, "responseTransitTimeSec : " + getResponseTransitTime(resIAT));
299299
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,12 @@ public static Element createElement(
542542
}
543543

544544
/**
545-
* get response issued time in seconds
545+
* get response issued time
546546
*
547547
* @param responseTime
548548
* @return long
549549
*/
550-
public static long getResponseIssuedAtTimeInSecs(String responseTime) {
550+
public static long getResponseIssuedAtTime(String responseTime) {
551551
return parseLong(responseTime, 0L);
552552
}
553553

java/src/main/resources/cybs.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ timeout=130
6565

6666
# logging should normally be disabled in production as it would slow down the
6767
# processing. Enable it only when troubleshooting an issue.
68-
enableLog=true
68+
enableLog=false
6969
logDirectory=../../logs
7070
logMaximumSize=10
7171

java/src/test/java/com/cybersource/ws/client/CustomHttpConnectionClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void release() {
4949
}
5050

5151
@Override
52-
void postDocument(Document request, long requestSentTime) throws IOException,
52+
void postDocument(Document request, long startTime) throws IOException,
5353
TransformerConfigurationException, TransformerException,
5454
MalformedURLException, ProtocolException {
5555
HttpClient httpClient = new HttpClient();

samples/nvp/cybs.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ timeout=130
6565

6666
# logging should normally be disabled in production as it would slow down the
6767
# processing. Enable it only when troubleshooting an issue.
68-
enableLog=true
68+
enableLog=false
6969
logDirectory=../../logs
7070
logMaximumSize=10
7171

0 commit comments

Comments
 (0)