cleanup with findbugs

This commit is contained in:
jinyu 2016-01-14 12:03:21 +08:00
parent c0f0705519
commit efa08c3bf4
4 changed files with 20 additions and 21 deletions

View File

@ -9,7 +9,7 @@ weixin4j
------- -------
* **weixin4j-base** * **weixin4j-base**
`微信支付(刷卡/扫码/JS/APP/WAP/现金红包/企业付款)` `Http Client实现&微信支付(刷卡/扫码/JS/APP/WAP/现金红包/企业付款)`
* **weixin4j-mp** * **weixin4j-mp**

View File

@ -551,7 +551,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
* response header. * response header.
*/ */
public boolean getAccessControlAllowCredentials() { public boolean getAccessControlAllowCredentials() {
return new Boolean(getFirst(ACCESS_CONTROL_ALLOW_CREDENTIALS)); return Boolean.valueOf(getFirst(ACCESS_CONTROL_ALLOW_CREDENTIALS));
} }
/** /**

View File

@ -134,24 +134,21 @@ public class SimpleHttpClient extends AbstractHttpClient implements HttpClient {
HttpEntity httpEntity = request.getEntity(); HttpEntity httpEntity = request.getEntity();
if (httpEntity != null) { if (httpEntity != null) {
connection.setUseCaches(false); connection.setUseCaches(false);
if (httpEntity != null) { // Read Out Exception when connection.disconnect();
// Read Out Exception when connection.disconnect(); /*
/* * if (httpEntity.getContentLength() > 0l) {
* if (httpEntity.getContentLength() > 0l) { * connection.setFixedLengthStreamingMode(httpEntity
* connection.setFixedLengthStreamingMode(httpEntity * .getContentLength()); } else { connection
* .getContentLength()); } else { connection * .setChunkedStreamingMode(params != null ? params
* .setChunkedStreamingMode(params != null ? params * .getChunkSize() : 4096); }
* .getChunkSize() : 4096); } */
*/ if (httpEntity.getContentLength() > 0l) {
if (httpEntity.getContentLength() > 0l) { connection.setRequestProperty(HttpHeaders.CONTENT_LENGTH,
connection.setRequestProperty( Long.toString(httpEntity.getContentLength()));
HttpHeaders.CONTENT_LENGTH, }
Long.toString(httpEntity.getContentLength())); if (httpEntity.getContentType() != null) {
} connection.setRequestProperty(HttpHeaders.CONTENT_TYPE,
if (httpEntity.getContentType() != null) { httpEntity.getContentType().getMimeType());
connection.setRequestProperty(HttpHeaders.CONTENT_TYPE,
httpEntity.getContentType().getMimeType());
}
} }
} }
// connect // connect

View File

@ -107,7 +107,8 @@ public class Netty4HttpClient extends AbstractHttpClient {
} }
} }
}; };
InetSocketAddress address = useProxy ? (InetSocketAddress) params.getProxy().address() : new InetSocketAddress( InetSocketAddress address = useProxy ? (InetSocketAddress) params
.getProxy().address() : new InetSocketAddress(
InetAddress.getByName(uri.getHost()), getPort(uri)); InetAddress.getByName(uri.getHost()), getPort(uri));
bootstrap.connect(address).syncUninterruptibly() bootstrap.connect(address).syncUninterruptibly()
.addListener(listener); .addListener(listener);
@ -188,6 +189,7 @@ public class Netty4HttpClient extends AbstractHttpClient {
Entry<String, List<String>> header = headerIterator.next(); Entry<String, List<String>> header = headerIterator.next();
uriRequest.headers().set(header.getKey(), header.getValue()); uriRequest.headers().set(header.getKey(), header.getValue());
} }
uriRequest.headers().set(HttpHeaders.ACCEPT_CHARSET, "utf-8");
uriRequest.headers().set(HttpHeaders.CONNECTION, uriRequest.headers().set(HttpHeaders.CONNECTION,
io.netty.handler.codec.http.HttpHeaders.Values.CLOSE); io.netty.handler.codec.http.HttpHeaders.Values.CLOSE);
return uriRequest; return uriRequest;