Skip to content

Commit 106586b

Browse files
committed
fixing some static scan issues
1 parent 45e89b4 commit 106586b

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

src/main/java/net/authorize/apicore/controller/base/ApiOperationBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.authorize.apicore.contract.v1.MessagesType;
1515
import net.authorize.apicore.contract.v1.MessagesType.Message;
1616
import net.authorize.util.HttpUtility;
17+
import net.authorize.util.LogHelper;
1718

1819
import org.apache.commons.logging.Log;
1920
import org.apache.commons.logging.LogFactory;
@@ -152,7 +153,7 @@ public void execute(Environment environment) {
152153
this.setResultStatus();
153154

154155
} else {
155-
logger.info(String.format("Got a 'null' Response for request:'%s'\n", this.getApiRequest()));
156+
logger.info(String.format("Got a 'null' Response for request:'%s'%s", this.getApiRequest(), LogHelper.LineSeparator));
156157
}
157158
afterExecute();
158159
}

src/main/java/net/authorize/util/HttpCallTask.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.List;
66
import java.util.concurrent.Callable;
77

8-
import javax.xml.bind.JAXBElement;
98
import javax.xml.bind.JAXBException;
109
import javax.xml.bind.UnmarshalException;
1110

@@ -15,8 +14,6 @@
1514
import net.authorize.apicore.contract.v1.MessageTypeEnum;
1615
import net.authorize.apicore.contract.v1.MessagesType;
1716
import net.authorize.apicore.contract.v1.MessagesType.Message;
18-
import net.authorize.apicore.contract.v1.ObjectFactory;
19-
//import net.authorize.apicore.controller.base.ErrorResponse;
2017

2118
import org.apache.commons.logging.Log;
2219
import org.apache.commons.logging.LogFactory;
@@ -25,6 +22,7 @@
2522
import org.apache.http.client.ClientProtocolException;
2623
import org.apache.http.client.methods.HttpPost;
2724
import org.apache.http.impl.client.DefaultHttpClient;
25+
//import net.authorize.apicore.controller.base.ErrorResponse;
2826

2927
/**
3028
* Callable task to make http calls in future
@@ -79,7 +77,7 @@ public ANetApiResponse call() throws Exception {
7977

8078
HttpEntity entity = httpResponse.getEntity();
8179
// get the raw data being received
82-
InputStream instream = (InputStream)entity.getContent();
80+
InputStream instream = entity.getContent();
8381
buffer.append(HttpUtility.convertStreamToString(instream));
8482
}
8583
}

src/main/java/net/authorize/util/HttpUtility.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static HttpPost createPostRequest(Environment env, ANetApiRequest request) throw
6262
httpPost.setHeader("Content-Type", "text/xml; charset=utf-8");
6363

6464
String xmlRequest = XmlUtility.getXml(request);
65-
logger.info(String.format("Request: '\n%s\n'", xmlRequest));
65+
logger.info(String.format("Request: '%s%s%s'", LogHelper.LineSeparator, xmlRequest, LogHelper.LineSeparator));
6666
httpPost.setEntity(new StringEntity(xmlRequest));
6767
}
6868

@@ -115,10 +115,6 @@ public static String convertStreamToString(InputStream is) {
115115
throw new NullPointerException("Unable to create BomStriper from the input stream");
116116
}
117117

118-
InputStreamReader isr = new InputStreamReader(bomStripperStream) ;
119-
BufferedReader reader = new BufferedReader(isr);
120-
StringBuilder sb = new StringBuilder();
121-
122118
//strip BOM if exists, the funny upto 3 bytes at the begining of stream identifying the char encoding
123119
try {
124120
bomStripperStream.skipBOM();
@@ -127,10 +123,16 @@ public static String convertStreamToString(InputStream is) {
127123
}
128124

129125
String line = null;
126+
InputStreamReader isr = null;
127+
BufferedReader reader = null;
128+
StringBuilder sb = null;
130129
//read the stream
131130
try {
131+
isr = new InputStreamReader(bomStripperStream) ;
132+
reader = new BufferedReader(isr);
133+
sb = new StringBuilder();
132134
while ((line = reader.readLine()) != null) {
133-
sb.append(line + "\n");
135+
sb.append(line).append(LogHelper.LineSeparator);
134136
}
135137
} catch (IOException e) {
136138
logger.warn(String.format("Exception reading data from Stream: '%s'", e.getMessage()));

src/main/java/net/authorize/util/LogHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
public final class LogHelper {
66

7+
public static String LineSeparator = System.getProperty("line.separator");
8+
79
private LogHelper() {
810
}
911

src/test/java/net/authorize/EnvironmentTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void testInternetConnectionViaProxy() {
3636

3737
for (String property : UnitTestData.getPropertiesList()) {
3838
if ( !property.toLowerCase().contains("password")) {
39-
System.out.printf("Property '%s'\n", property);
39+
System.out.printf("Property '%s'%s", property, net.authorize.util.LogHelper.LineSeparator);
4040
}
4141
}
4242
}

src/test/java/net/authorize/UnitTestData.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import net.authorize.data.echeck.BankAccountType;
1919
import net.authorize.data.echeck.ECheckType;
2020
import net.authorize.util.Constants;
21+
import net.authorize.util.LogHelper;
2122

2223
public abstract class UnitTestData {
2324
protected static String apiLoginID ;
@@ -192,7 +193,7 @@ public static HashMap<String, String> getProxySettings() {
192193

193194
/*
194195
if ( !property.toLowerCase().contains("password")) {
195-
System.out.printf("Values: %s, Property='%s', Environment='%s'\n", property, propValue, envValue);
196+
System.out.printf("Values: %s, Property='%s', Environment='%s'%s", property, propValue, envValue, LogHelper.LineSeparator);
196197
}
197198
*/
198199
if (null != propValue) {
@@ -230,15 +231,15 @@ private static boolean internetAccessible() {
230231
{
231232
URLConnection conn = ( new URL(url)).openConnection();
232233
conn.connect();
233-
//System.out.printf( "Connection to %s is ok \n", url);
234+
//System.out.printf( "Connection to %s is ok %s", url, LogHelper.LineSeparator);
234235
conn = null;
235236
url = null;
236237
}
237238
internetAccessible = true;
238239
} catch (final MalformedURLException e) {
239-
//System.err.printf("MalformedURLException accessing: %s, Message: %s\n", url.toString(), e.getMessage());
240+
//System.err.printf("MalformedURLException accessing: %s, Message: %s%s", url.toString(), e.getMessage(), LogHelper.LineSeparator);
240241
} catch (final IOException e) {
241-
//System.err.printf("IOException accessing: %s, Message: %s\n", url.toString(), e.getMessage());
242+
//System.err.printf("IOException accessing: %s, Message: %s%s", url.toString(), e.getMessage(), LogHelper.LineSeparator);
242243
}
243244
}
244245

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy