You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2015/05/24 16:24:28 UTC
svn commit: r1681461 [2/3] - in /httpcomponents/httpclient/trunk: ./
fluent-hc/src/examples/org/apache/http/client/fluent/
fluent-hc/src/main/java/org/apache/http/client/fluent/
httpclient-cache/src/main/java/org/apache/http/client/cache/ httpclient-ca...
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java Sun May 24 14:24:26 2015
@@ -47,8 +47,7 @@ public class ClientChunkEncodedPost {
System.out.println("File path not given");
System.exit(1);
}
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
+ try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpPost httppost = new HttpPost("http://localhost/");
File file = new File(args[0]);
@@ -65,16 +64,11 @@ public class ClientChunkEncodedPost {
httppost.setEntity(reqEntity);
System.out.println("Executing request: " + httppost.getRequestLine());
- CloseableHttpResponse response = httpclient.execute(httppost);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(httppost)) {
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
EntityUtils.consume(response.getEntity());
- } finally {
- response.close();
}
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java Sun May 24 14:24:26 2015
@@ -212,24 +212,23 @@ public class ClientConfiguration {
.build();
// Create an HttpClient with the given custom dependencies and configuration.
- CloseableHttpClient httpclient = HttpClients.custom()
- .setConnectionManager(connManager)
- .setDefaultCookieStore(cookieStore)
- .setDefaultCredentialsProvider(credentialsProvider)
- .setProxy(new HttpHost("myproxy", 8080))
- .setDefaultRequestConfig(defaultRequestConfig)
- .build();
- try {
+ try (CloseableHttpClient httpclient = HttpClients.custom()
+ .setConnectionManager(connManager)
+ .setDefaultCookieStore(cookieStore)
+ .setDefaultCredentialsProvider(credentialsProvider)
+ .setProxy(new HttpHost("myproxy", 8080))
+ .setDefaultRequestConfig(defaultRequestConfig)
+ .build()) {
HttpGet httpget = new HttpGet("http://www.apache.org/");
// Request configuration can be overridden at the request level.
// They will take precedence over the one set at the client level.
RequestConfig requestConfig = RequestConfig.copy(defaultRequestConfig)
- .setSocketTimeout(5000)
- .setConnectTimeout(5000)
- .setConnectionRequestTimeout(5000)
- .setProxy(new HttpHost("myotherproxy", 8080))
- .build();
+ .setSocketTimeout(5000)
+ .setConnectTimeout(5000)
+ .setConnectionRequestTimeout(5000)
+ .setProxy(new HttpHost("myotherproxy", 8080))
+ .build();
httpget.setConfig(requestConfig);
// Execution context can be customized locally.
@@ -240,8 +239,7 @@ public class ClientConfiguration {
context.setCredentialsProvider(credentialsProvider);
System.out.println("executing request " + httpget.getURI());
- CloseableHttpResponse response = httpclient.execute(httpget, context);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(httpget, context)) {
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
@@ -270,11 +268,7 @@ public class ClientConfiguration {
// User security token
context.getUserToken();
- } finally {
- response.close();
}
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java Sun May 24 14:24:26 2015
@@ -43,13 +43,11 @@ import org.apache.http.impl.client.HttpC
public class ClientConnectionRelease {
public final static void main(String[] args) throws Exception {
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
+ try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpGet httpget = new HttpGet("http://localhost/");
System.out.println("Executing request " + httpget.getRequestLine());
- CloseableHttpResponse response = httpclient.execute(httpget);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(httpget)) {
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
@@ -59,24 +57,16 @@ public class ClientConnectionRelease {
// If the response does not enclose an entity, there is no need
// to bother about connection release
if (entity != null) {
- InputStream instream = entity.getContent();
- try {
+ try (InputStream instream = entity.getContent()) {
instream.read();
// do something useful with the response
} catch (IOException ex) {
// In case of an IOException the connection will be released
// back to the connection manager automatically
throw ex;
- } finally {
- // Closing the input stream will trigger connection release
- instream.close();
}
}
- } finally {
- response.close();
}
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java Sun May 24 14:24:26 2015
@@ -46,8 +46,7 @@ import org.apache.http.util.EntityUtils;
public class ClientCustomContext {
public final static void main(String[] args) throws Exception {
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
+ try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
// Create a local instance of cookie store
CookieStore cookieStore = new BasicCookieStore();
@@ -60,8 +59,7 @@ public class ClientCustomContext {
System.out.println("Executing request " + httpget.getRequestLine());
// Pass local context as a parameter
- CloseableHttpResponse response = httpclient.execute(httpget, localContext);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(httpget, localContext)) {
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
List<Cookie> cookies = cookieStore.getCookies();
@@ -69,11 +67,7 @@ public class ClientCustomContext {
System.out.println("Local cookie: " + cookies.get(i));
}
EntityUtils.consume(response.getEntity());
- } finally {
- response.close();
}
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomPublicSuffixList.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomPublicSuffixList.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomPublicSuffixList.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomPublicSuffixList.java Sun May 24 14:24:26 2015
@@ -67,28 +67,22 @@ public class ClientCustomPublicSuffixLis
.register(CookieSpecs.STANDARD_STRICT, cookieSpecProvider)
.build();
- CloseableHttpClient httpclient = HttpClients.custom()
+ try (CloseableHttpClient httpclient = HttpClients.custom()
.setSSLHostnameVerifier(hostnameVerifier)
.setDefaultCookieSpecRegistry(cookieSpecRegistry)
- .build();
- try {
+ .build()) {
HttpGet httpget = new HttpGet("https://remotehost/");
System.out.println("executing request " + httpget.getRequestLine());
- CloseableHttpResponse response = httpclient.execute(httpget);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(httpget)) {
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
EntityUtils.consume(entity);
- } finally {
- response.close();
}
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java Sun May 24 14:24:26 2015
@@ -58,27 +58,21 @@ public class ClientCustomSSL {
new String[] { "TLSv1" },
null,
SSLConnectionSocketFactory.getDefaultHostnameVerifier());
- CloseableHttpClient httpclient = HttpClients.custom()
+ try (CloseableHttpClient httpclient = HttpClients.custom()
.setSSLSocketFactory(sslsf)
- .build();
- try {
+ .build()) {
HttpGet httpget = new HttpGet("https://localhost/");
System.out.println("executing request " + httpget.getRequestLine());
- CloseableHttpResponse response = httpclient.execute(httpget);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(httpget)) {
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
EntityUtils.consume(entity);
- } finally {
- response.close();
}
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java Sun May 24 14:24:26 2015
@@ -45,17 +45,16 @@ public class ClientEvictExpiredConnectio
public static void main(String[] args) throws Exception {
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(100);
- CloseableHttpClient httpclient = HttpClients.custom()
+ try (CloseableHttpClient httpclient = HttpClients.custom()
.setConnectionManager(cm)
.evictExpiredConnections()
.evictIdleConnections(5L, TimeUnit.SECONDS)
- .build();
- try {
+ .build()) {
// create an array of URIs to perform GETs on
String[] urisToGet = {
- "http://hc.apache.org/",
- "http://hc.apache.org/httpcomponents-core-ga/",
- "http://hc.apache.org/httpcomponents-client-ga/",
+ "http://hc.apache.org/",
+ "http://hc.apache.org/httpcomponents-core-ga/",
+ "http://hc.apache.org/httpcomponents-client-ga/",
};
for (int i = 0; i < urisToGet.length; i++) {
@@ -64,13 +63,10 @@ public class ClientEvictExpiredConnectio
System.out.println("Executing request " + requestURI);
- CloseableHttpResponse response = httpclient.execute(request);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(request)) {
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
EntityUtils.consume(response.getEntity());
- } finally {
- response.close();
}
}
@@ -83,8 +79,6 @@ public class ClientEvictExpiredConnectio
PoolStats stats2 = cm.getTotalStats();
System.out.println("Connections kept alive: " + stats2.getAvailable());
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java Sun May 24 14:24:26 2015
@@ -43,8 +43,7 @@ import org.apache.http.util.EntityUtils;
public class ClientExecuteProxy {
public static void main(String[] args)throws Exception {
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
+ try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpHost target = new HttpHost("localhost", 443, "https");
HttpHost proxy = new HttpHost("127.0.0.1", 8080, "http");
@@ -56,16 +55,11 @@ public class ClientExecuteProxy {
System.out.println("Executing request " + request.getRequestLine() + " to " + target + " via " + proxy);
- CloseableHttpResponse response = httpclient.execute(target, request);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(target, request)) {
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
EntityUtils.consume(response.getEntity());
- } finally {
- response.close();
}
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteSOCKS.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteSOCKS.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteSOCKS.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteSOCKS.java Sun May 24 14:24:26 2015
@@ -59,10 +59,9 @@ public class ClientExecuteSOCKS {
.register("http", new MyConnectionSocketFactory())
.build();
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(reg);
- CloseableHttpClient httpclient = HttpClients.custom()
+ try (CloseableHttpClient httpclient = HttpClients.custom()
.setConnectionManager(cm)
- .build();
- try {
+ .build()) {
InetSocketAddress socksaddr = new InetSocketAddress("mysockshost", 1234);
HttpClientContext context = HttpClientContext.create();
context.setAttribute("socks.address", socksaddr);
@@ -71,16 +70,11 @@ public class ClientExecuteSOCKS {
HttpGet request = new HttpGet("/");
System.out.println("Executing request " + request + " to " + target + " via SOCKS proxy " + socksaddr);
- CloseableHttpResponse response = httpclient.execute(target, request, context);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(target, request, context)) {
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
EntityUtils.consume(response.getEntity());
- } finally {
- response.close();
}
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java Sun May 24 14:24:26 2015
@@ -48,13 +48,11 @@ public class ClientFormLogin {
public static void main(String[] args) throws Exception {
BasicCookieStore cookieStore = new BasicCookieStore();
- CloseableHttpClient httpclient = HttpClients.custom()
+ try (CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultCookieStore(cookieStore)
- .build();
- try {
+ .build()) {
HttpGet httpget = new HttpGet("https://someportal/");
- CloseableHttpResponse response1 = httpclient.execute(httpget);
- try {
+ try (CloseableHttpResponse response1 = httpclient.execute(httpget)) {
HttpEntity entity = response1.getEntity();
System.out.println("Login form get: " + response1.getStatusLine());
@@ -69,8 +67,6 @@ public class ClientFormLogin {
System.out.println("- " + cookies.get(i).toString());
}
}
- } finally {
- response1.close();
}
HttpUriRequest login = RequestBuilder.post()
@@ -78,8 +74,7 @@ public class ClientFormLogin {
.addParameter("IDToken1", "username")
.addParameter("IDToken2", "password")
.build();
- CloseableHttpResponse response2 = httpclient.execute(login);
- try {
+ try (CloseableHttpResponse response2 = httpclient.execute(login)) {
HttpEntity entity = response2.getEntity();
System.out.println("Login form get: " + response2.getStatusLine());
@@ -94,11 +89,7 @@ public class ClientFormLogin {
System.out.println("- " + cookies.get(i).toString());
}
}
- } finally {
- response2.close();
}
- } finally {
- httpclient.close();
}
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java Sun May 24 14:24:26 2015
@@ -49,15 +49,14 @@ public class ClientMultiThreadedExecutio
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(100);
- CloseableHttpClient httpclient = HttpClients.custom()
+ try (CloseableHttpClient httpclient = HttpClients.custom()
.setConnectionManager(cm)
- .build();
- try {
+ .build()) {
// create an array of URIs to perform GETs on
String[] urisToGet = {
- "http://hc.apache.org/",
- "http://hc.apache.org/httpcomponents-core-ga/",
- "http://hc.apache.org/httpcomponents-client-ga/",
+ "http://hc.apache.org/",
+ "http://hc.apache.org/httpcomponents-core-ga/",
+ "http://hc.apache.org/httpcomponents-client-ga/",
};
// create a thread for each URI
@@ -77,8 +76,6 @@ public class ClientMultiThreadedExecutio
threads[j].join();
}
- } finally {
- httpclient.close();
}
}
@@ -106,8 +103,7 @@ public class ClientMultiThreadedExecutio
public void run() {
try {
System.out.println(id + " - about to get something from " + httpget.getURI());
- CloseableHttpResponse response = httpClient.execute(httpget, context);
- try {
+ try (CloseableHttpResponse response = httpClient.execute(httpget, context)) {
System.out.println(id + " - get executed");
// get the response body as an array of bytes
HttpEntity entity = response.getEntity();
@@ -115,8 +111,6 @@ public class ClientMultiThreadedExecutio
byte[] bytes = EntityUtils.toByteArray(entity);
System.out.println(id + " - " + bytes.length + " bytes read");
}
- } finally {
- response.close();
}
} catch (Exception e) {
System.out.println(id + " - error: " + e);
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java Sun May 24 14:24:26 2015
@@ -57,9 +57,8 @@ public class ClientPreemptiveBasicAuthen
credsProvider.setCredentials(
new AuthScope(target.getHostName(), target.getPort()),
new UsernamePasswordCredentials("username", "password"));
- CloseableHttpClient httpclient = HttpClients.custom()
- .setDefaultCredentialsProvider(credsProvider).build();
- try {
+ try (CloseableHttpClient httpclient = HttpClients.custom()
+ .setDefaultCredentialsProvider(credsProvider).build()) {
// Create AuthCache instance
AuthCache authCache = new BasicAuthCache();
@@ -76,17 +75,12 @@ public class ClientPreemptiveBasicAuthen
System.out.println("Executing request " + httpget.getRequestLine() + " to target " + target);
for (int i = 0; i < 3; i++) {
- CloseableHttpResponse response = httpclient.execute(target, httpget, localContext);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(target, httpget, localContext)) {
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
EntityUtils.consume(response.getEntity());
- } finally {
- response.close();
}
}
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java Sun May 24 14:24:26 2015
@@ -58,10 +58,9 @@ public class ClientPreemptiveDigestAuthe
credsProvider.setCredentials(
new AuthScope(target.getHostName(), target.getPort()),
new UsernamePasswordCredentials("username", "password"));
- CloseableHttpClient httpclient = HttpClients.custom()
+ try (CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultCredentialsProvider(credsProvider)
- .build();
- try {
+ .build()) {
// Create AuthCache instance
AuthCache authCache = new BasicAuthCache();
@@ -82,17 +81,12 @@ public class ClientPreemptiveDigestAuthe
System.out.println("Executing request " + httpget.getRequestLine() + " to target " + target);
for (int i = 0; i < 3; i++) {
- CloseableHttpResponse response = httpclient.execute(target, httpget, localContext);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(target, httpget, localContext)) {
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
EntityUtils.consume(response.getEntity());
- } finally {
- response.close();
}
}
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java Sun May 24 14:24:26 2015
@@ -49,30 +49,24 @@ public class ClientProxyAuthentication {
credsProvider.setCredentials(
new AuthScope("localhost", 8080),
new UsernamePasswordCredentials("username", "password"));
- CloseableHttpClient httpclient = HttpClients.custom()
- .setDefaultCredentialsProvider(credsProvider).build();
- try {
+ try (CloseableHttpClient httpclient = HttpClients.custom()
+ .setDefaultCredentialsProvider(credsProvider).build()) {
HttpHost target = new HttpHost("www.verisign.com", 443, "https");
HttpHost proxy = new HttpHost("localhost", 8080);
RequestConfig config = RequestConfig.custom()
- .setProxy(proxy)
- .build();
+ .setProxy(proxy)
+ .build();
HttpGet httpget = new HttpGet("/");
httpget.setConfig(config);
System.out.println("Executing request " + httpget.getRequestLine() + " to " + target + " via " + proxy);
- CloseableHttpResponse response = httpclient.execute(target, httpget);
- try {
+ try (CloseableHttpResponse response = httpclient.execute(target, httpget)) {
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
EntityUtils.consume(response.getEntity());
- } finally {
- response.close();
}
- } finally {
- httpclient.close();
}
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java Sun May 24 14:24:26 2015
@@ -51,9 +51,8 @@ public class ClientWithRequestFuture {
.setMaxConnPerRoute(5)
.setMaxConnTotal(5).build();
ExecutorService execService = Executors.newFixedThreadPool(5);
- FutureRequestExecutionService requestExecService = new FutureRequestExecutionService(
- httpclient, execService);
- try {
+ try (FutureRequestExecutionService requestExecService = new FutureRequestExecutionService(
+ httpclient, execService)) {
// Because things are asynchronous, you must provide a ResponseHandler
ResponseHandler<Boolean> handler = new ResponseHandler<Boolean>() {
@Override
@@ -68,7 +67,7 @@ public class ClientWithRequestFuture {
HttpRequestFutureTask<Boolean> futureTask1 = requestExecService.execute(request1,
HttpClientContext.create(), handler);
Boolean wasItOk1 = futureTask1.get();
- System.out.println("It was ok? " + wasItOk1);
+ System.out.println("It was ok? " + wasItOk1);
// Cancel a request
try {
@@ -87,7 +86,7 @@ public class ClientWithRequestFuture {
HttpRequestFutureTask<Boolean> futureTask3 = requestExecService.execute(request3,
HttpClientContext.create(), handler);
Boolean wasItOk3 = futureTask3.get(10, TimeUnit.SECONDS);
- System.out.println("It was ok? " + wasItOk3);
+ System.out.println("It was ok? " + wasItOk3);
FutureCallback<Boolean> callback = new FutureCallback<Boolean>() {
@Override
@@ -113,9 +112,7 @@ public class ClientWithRequestFuture {
HttpRequestFutureTask<Boolean> futureTask4 = requestExecService.execute(request4,
HttpClientContext.create(), handler, callback);
Boolean wasItOk4 = futureTask4.get(10, TimeUnit.SECONDS);
- System.out.println("It was ok? " + wasItOk4);
- } finally {
- requestExecService.close();
+ System.out.println("It was ok? " + wasItOk4);
}
}
}
\ No newline at end of file
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java Sun May 24 14:24:26 2015
@@ -45,8 +45,7 @@ import org.apache.http.util.EntityUtils;
public class ClientWithResponseHandler {
public final static void main(String[] args) throws Exception {
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
+ try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpGet httpget = new HttpGet("http://localhost/");
System.out.println("Executing request " + httpget.getRequestLine());
@@ -70,8 +69,6 @@ public class ClientWithResponseHandler {
String responseBody = httpclient.execute(httpget, responseHandler);
System.out.println("----------------------------------------");
System.out.println(responseBody);
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java Sun May 24 14:24:26 2015
@@ -49,8 +49,7 @@ public class ProxyTunnelDemo {
HttpHost target = new HttpHost("www.yahoo.com", 80);
HttpHost proxy = new HttpHost("localhost", 8888);
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("user", "pwd");
- Socket socket = proxyClient.tunnel(proxy, target, credentials);
- try {
+ try (Socket socket = proxyClient.tunnel(proxy, target, credentials)) {
Writer out = new OutputStreamWriter(socket.getOutputStream(), HTTP.DEF_CONTENT_CHARSET);
out.write("GET / HTTP/1.1\r\n");
out.write("Host: " + target.toHostString() + "\r\n");
@@ -64,8 +63,6 @@ public class ProxyTunnelDemo {
while ((line = in.readLine()) != null) {
System.out.println(line);
}
- } finally {
- socket.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/QuickStart.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/QuickStart.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/QuickStart.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/QuickStart.java Sun May 24 14:24:26 2015
@@ -43,10 +43,8 @@ import org.apache.http.util.EntityUtils;
public class QuickStart {
public static void main(String[] args) throws Exception {
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
+ try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet("http://targethost/homepage");
- CloseableHttpResponse response1 = httpclient.execute(httpGet);
// The underlying HTTP connection is still held by the response object
// to allow the response content to be streamed directly from the network socket.
// In order to ensure correct deallocation of system resources
@@ -54,34 +52,27 @@ public class QuickStart {
// Please note that if response content is not fully consumed the underlying
// connection cannot be safely re-used and will be shut down and discarded
// by the connection manager.
- try {
+ try (CloseableHttpResponse response1 = httpclient.execute(httpGet)) {
System.out.println(response1.getStatusLine());
HttpEntity entity1 = response1.getEntity();
// do something useful with the response body
// and ensure it is fully consumed
EntityUtils.consume(entity1);
- } finally {
- response1.close();
}
HttpPost httpPost = new HttpPost("http://targethost/login");
- List <NameValuePair> nvps = new ArrayList <NameValuePair>();
+ List<NameValuePair> nvps = new ArrayList<>();
nvps.add(new BasicNameValuePair("username", "vip"));
nvps.add(new BasicNameValuePair("password", "secret"));
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
- CloseableHttpResponse response2 = httpclient.execute(httpPost);
- try {
+ try (CloseableHttpResponse response2 = httpclient.execute(httpPost)) {
System.out.println(response2.getStatusLine());
HttpEntity entity2 = response2.getEntity();
// do something useful with the response body
// and ensure it is fully consumed
EntityUtils.consume(entity2);
- } finally {
- response2.close();
}
- } finally {
- httpclient.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java Sun May 24 14:24:26 2015
@@ -87,15 +87,12 @@ public class DecompressingEntity extends
@Override
public void writeTo(final OutputStream outstream) throws IOException {
Args.notNull(outstream, "Output stream");
- final InputStream instream = getContent();
- try {
+ try (InputStream instream = getContent()) {
final byte[] buffer = new byte[BUFFER_SIZE];
int l;
while ((l = instream.read(buffer)) != -1) {
outstream.write(buffer, 0, l);
}
- } finally {
- instream.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/AbstractExecutionAwareRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/AbstractExecutionAwareRequest.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/AbstractExecutionAwareRequest.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/AbstractExecutionAwareRequest.java Sun May 24 14:24:26 2015
@@ -43,7 +43,7 @@ public abstract class AbstractExecutionA
protected AbstractExecutionAwareRequest() {
super();
this.aborted = new AtomicBoolean(false);
- this.cancellableRef = new AtomicReference<Cancellable>(null);
+ this.cancellableRef = new AtomicReference<>(null);
}
public void abort() {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java Sun May 24 14:24:26 2015
@@ -86,7 +86,7 @@ public class HttpOptions extends HttpReq
Args.notNull(response, "HTTP response");
final HeaderIterator it = response.headerIterator("Allow");
- final Set<String> methods = new HashSet<String>();
+ final Set<String> methods = new HashSet<>();
while (it.hasNext()) {
final Header header = it.nextHeader();
final HeaderElement[] elements = header.getElements();
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java Sun May 24 14:24:26 2015
@@ -440,14 +440,14 @@ public class RequestBuilder {
}
public List<NameValuePair> getParameters() {
- return parameters != null ? new ArrayList<NameValuePair>(parameters) :
+ return parameters != null ? new ArrayList<>(parameters) :
new ArrayList<NameValuePair>();
}
public RequestBuilder addParameter(final NameValuePair nvp) {
Args.notNull(nvp, "Name value pair");
if (parameters == null) {
- parameters = new LinkedList<NameValuePair>();
+ parameters = new LinkedList<>();
}
parameters.add(nvp);
return this;
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java Sun May 24 14:24:26 2015
@@ -157,7 +157,7 @@ public class RequestAddCookies implement
// Get all cookies available in the HTTP state
final List<Cookie> cookies = cookieStore.getCookies();
// Find cookies matching the given origin
- final List<Cookie> matchedCookies = new ArrayList<Cookie>();
+ final List<Cookie> matchedCookies = new ArrayList<>();
final Date now = new Date();
boolean expired = false;
for (final Cookie cookie : cookies) {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java Sun May 24 14:24:26 2015
@@ -226,9 +226,9 @@ public final class DateUtils {
final SoftReference<Map<String, SimpleDateFormat>> ref = THREADLOCAL_FORMATS.get();
Map<String, SimpleDateFormat> formats = ref.get();
if (formats == null) {
- formats = new HashMap<String, SimpleDateFormat>();
+ formats = new HashMap<>();
THREADLOCAL_FORMATS.set(
- new SoftReference<Map<String, SimpleDateFormat>>(formats));
+ new SoftReference<>(formats));
}
SimpleDateFormat format = formats.get(pattern);
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java Sun May 24 14:24:26 2015
@@ -280,7 +280,7 @@ public class URIBuilder {
*/
public URIBuilder setParameters(final List <NameValuePair> nvps) {
if (this.queryParams == null) {
- this.queryParams = new ArrayList<NameValuePair>();
+ this.queryParams = new ArrayList<>();
} else {
this.queryParams.clear();
}
@@ -303,7 +303,7 @@ public class URIBuilder {
*/
public URIBuilder addParameters(final List <NameValuePair> nvps) {
if (this.queryParams == null) {
- this.queryParams = new ArrayList<NameValuePair>();
+ this.queryParams = new ArrayList<>();
}
this.queryParams.addAll(nvps);
this.encodedQuery = null;
@@ -324,7 +324,7 @@ public class URIBuilder {
*/
public URIBuilder setParameters(final NameValuePair... nvps) {
if (this.queryParams == null) {
- this.queryParams = new ArrayList<NameValuePair>();
+ this.queryParams = new ArrayList<>();
} else {
this.queryParams.clear();
}
@@ -347,7 +347,7 @@ public class URIBuilder {
*/
public URIBuilder addParameter(final String param, final String value) {
if (this.queryParams == null) {
- this.queryParams = new ArrayList<NameValuePair>();
+ this.queryParams = new ArrayList<>();
}
this.queryParams.add(new BasicNameValuePair(param, value));
this.encodedQuery = null;
@@ -366,7 +366,7 @@ public class URIBuilder {
*/
public URIBuilder setParameter(final String param, final String value) {
if (this.queryParams == null) {
- this.queryParams = new ArrayList<NameValuePair>();
+ this.queryParams = new ArrayList<>();
}
if (!this.queryParams.isEmpty()) {
for (final Iterator<NameValuePair> it = this.queryParams.iterator(); it.hasNext(); ) {
@@ -459,9 +459,9 @@ public class URIBuilder {
public List<NameValuePair> getQueryParams() {
if (this.queryParams != null) {
- return new ArrayList<NameValuePair>(this.queryParams);
+ return new ArrayList<>(this.queryParams);
} else {
- return new ArrayList<NameValuePair>();
+ return new ArrayList<>();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java Sun May 24 14:24:26 2015
@@ -227,7 +227,7 @@ public class URIUtils {
final String path = builder.getPath();
if (path != null && !path.equals("/")) {
final String[] inputSegments = path.split("/");
- final Stack<String> outputSegments = new Stack<String>();
+ final Stack<String> outputSegments = new Stack<>();
for (final String inputSegment : inputSegments) {
if ((inputSegment.isEmpty()) || (".".equals(inputSegment))) {
// Do nothing
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java Sun May 24 14:24:26 2015
@@ -218,7 +218,7 @@ public class URLEncodedUtils {
delimSet.set(separator);
}
final ParserCursor cursor = new ParserCursor(0, buf.length());
- final List<NameValuePair> list = new ArrayList<NameValuePair>();
+ final List<NameValuePair> list = new ArrayList<>();
while (!cursor.atEnd()) {
delimSet.set('=');
final String name = tokenParser.parseToken(buf, cursor, delimSet);
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java Sun May 24 14:24:26 2015
@@ -74,7 +74,7 @@ public final class HttpRoute implements
this.targetHost = normalize(target);
this.localAddress = local;
if (proxies != null && !proxies.isEmpty()) {
- this.proxyChain = new ArrayList<HttpHost>(proxies);
+ this.proxyChain = new ArrayList<>(proxies);
} else {
this.proxyChain = null;
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java Sun May 24 14:24:26 2015
@@ -247,8 +247,7 @@ public final class DefaultHostnameVerifi
if (value != null) {
return value.toString();
}
- } catch (NoSuchElementException ignore) {
- } catch (NamingException ignore) {
+ } catch (NoSuchElementException | NamingException ignore) {
}
}
}
@@ -272,7 +271,7 @@ public final class DefaultHostnameVerifi
if (type == subjectType) {
final String s = (String) list.get(1);
if (subjectAltList == null) {
- subjectAltList = new ArrayList<String>();
+ subjectAltList = new ArrayList<>();
}
subjectAltList.add(s);
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java Sun May 24 14:24:26 2015
@@ -308,7 +308,7 @@ public class SSLConnectionSocketFactory
} else {
// If supported protocols are not explicitly set, remove all SSL protocol versions
final String[] allProtocols = sslsock.getEnabledProtocols();
- final List<String> enabledProtocols = new ArrayList<String>(allProtocols.length);
+ final List<String> enabledProtocols = new ArrayList<>(allProtocols.length);
for (String protocol: allProtocols) {
if (!protocol.startsWith("SSL")) {
enabledProtocols.add(protocol);
@@ -371,7 +371,7 @@ public class SSLConnectionSocketFactory
this.log.debug(" peer principal: " + peer.toString());
final Collection<List<?>> altNames1 = x509.getSubjectAlternativeNames();
if (altNames1 != null) {
- final List<String> altNames = new ArrayList<String>();
+ final List<String> altNames = new ArrayList<>();
for (final List<?> aC : altNames1) {
if (!aC.isEmpty()) {
altNames.add((String) aC.get(1));
@@ -384,7 +384,7 @@ public class SSLConnectionSocketFactory
this.log.debug(" issuer principal: " + issuer.toString());
final Collection<List<?>> altNames2 = x509.getIssuerAlternativeNames();
if (altNames2 != null) {
- final List<String> altNames = new ArrayList<String>();
+ final List<String> altNames = new ArrayList<>();
for (final List<?> aC : altNames2) {
if (!aC.isEmpty()) {
altNames.add((String) aC.get(1));
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java Sun May 24 14:24:26 2015
@@ -56,8 +56,8 @@ public final class PublicSuffixListParse
* @throws java.io.IOException on error while reading from list
*/
public PublicSuffixList parse(final Reader reader) throws IOException {
- final List<String> rules = new ArrayList<String>();
- final List<String> exceptions = new ArrayList<String>();
+ final List<String> rules = new ArrayList<>();
+ final List<String> exceptions = new ArrayList<>();
final BufferedReader r = new BufferedReader(reader);
String line;
@@ -98,7 +98,7 @@ public final class PublicSuffixListParse
* @since 4.5
*/
public List<PublicSuffixList> parseByType(final Reader reader) throws IOException {
- final List<PublicSuffixList> result = new ArrayList<PublicSuffixList>(2);
+ final List<PublicSuffixList> result = new ArrayList<>(2);
final BufferedReader r = new BufferedReader(reader);
final StringBuilder sb = new StringBuilder(256);
@@ -147,12 +147,12 @@ public final class PublicSuffixListParse
if (isException) {
if (exceptions == null) {
- exceptions = new ArrayList<String>();
+ exceptions = new ArrayList<>();
}
exceptions.add(line);
} else {
if (rules == null) {
- rules = new ArrayList<String>();
+ rules = new ArrayList<>();
}
rules.add(line);
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java Sun May 24 14:24:26 2015
@@ -63,11 +63,11 @@ public final class PublicSuffixMatcher {
final DomainType domainType, final Collection<String> rules, final Collection<String> exceptions) {
Args.notNull(domainType, "Domain type");
Args.notNull(rules, "Domain suffix rules");
- this.rules = new ConcurrentHashMap<String, DomainType>(rules.size());
+ this.rules = new ConcurrentHashMap<>(rules.size());
for (String rule: rules) {
this.rules.put(rule, domainType);
}
- this.exceptions = new ConcurrentHashMap<String, DomainType>();
+ this.exceptions = new ConcurrentHashMap<>();
if (exceptions != null) {
for (String exception: exceptions) {
this.exceptions.put(exception, domainType);
@@ -80,8 +80,8 @@ public final class PublicSuffixMatcher {
*/
public PublicSuffixMatcher(final Collection<PublicSuffixList> lists) {
Args.notNull(lists, "Domain suffix lists");
- this.rules = new ConcurrentHashMap<String, DomainType>();
- this.exceptions = new ConcurrentHashMap<String, DomainType>();
+ this.rules = new ConcurrentHashMap<>();
+ this.exceptions = new ConcurrentHashMap<>();
for (PublicSuffixList list: lists) {
final DomainType domainType = list.getType();
final List<String> rules = list.getRules();
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java Sun May 24 14:24:26 2015
@@ -57,21 +57,15 @@ public final class PublicSuffixMatcherLo
public static PublicSuffixMatcher load(final URL url) throws IOException {
Args.notNull(url, "URL");
- final InputStream in = url.openStream();
- try {
+ try (InputStream in = url.openStream()) {
return load(in);
- } finally {
- in.close();
}
}
public static PublicSuffixMatcher load(final File file) throws IOException {
Args.notNull(file, "File");
- final InputStream in = new FileInputStream(file);
- try {
+ try (InputStream in = new FileInputStream(file)) {
return load(in);
- } finally {
- in.close();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java Sun May 24 14:24:26 2015
@@ -240,7 +240,7 @@ public class DigestScheme extends RFC261
algorithm = "MD5";
}
- final Set<String> qopset = new HashSet<String>(8);
+ final Set<String> qopset = new HashSet<>(8);
int qop = QOP_UNKNOWN;
final String qoplist = getParameter("qop");
if (qoplist != null) {
@@ -384,7 +384,7 @@ public class DigestScheme extends RFC261
}
buffer.append(": Digest ");
- final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(20);
+ final List<BasicNameValuePair> params = new ArrayList<>(20);
params.add(new BasicNameValuePair("username", uname));
params.add(new BasicNameValuePair("realm", realm));
params.add(new BasicNameValuePair("nonce", nonce));
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java Sun May 24 14:24:26 2015
@@ -68,7 +68,7 @@ public abstract class RFC2617Scheme exte
*/
public RFC2617Scheme(final Charset credentialsCharset) {
super();
- this.params = new HashMap<String, String>();
+ this.params = new HashMap<>();
this.credentialsCharset = credentialsCharset != null ? credentialsCharset : Consts.ASCII;
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java Sun May 24 14:24:26 2015
@@ -78,8 +78,8 @@ public class AIMDBackoffManager implemen
AIMDBackoffManager(final ConnPoolControl<HttpRoute> connPerRoute, final Clock clock) {
this.clock = clock;
this.connPerRoute = connPerRoute;
- this.lastRouteProbes = new HashMap<HttpRoute,Long>();
- this.lastRouteBackoffs = new HashMap<HttpRoute,Long>();
+ this.lastRouteProbes = new HashMap<>();
+ this.lastRouteBackoffs = new HashMap<>();
}
@Override
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java Sun May 24 14:24:26 2015
@@ -110,7 +110,7 @@ abstract class AuthenticationStrategyImp
final HttpContext context) throws MalformedChallengeException {
Args.notNull(response, "HTTP response");
final Header[] headers = response.getHeaders(this.headerName);
- final Map<String, Header> map = new HashMap<String, Header>(headers.length);
+ final Map<String, Header> map = new HashMap<>(headers.length);
for (final Header header : headers) {
final CharArrayBuffer buffer;
int pos;
@@ -154,7 +154,7 @@ abstract class AuthenticationStrategyImp
Args.notNull(context, "HTTP context");
final HttpClientContext clientContext = HttpClientContext.adapt(context);
- final Queue<AuthOption> options = new LinkedList<AuthOption>();
+ final Queue<AuthOption> options = new LinkedList<>();
final Lookup<AuthSchemeProvider> registry = clientContext.getAuthSchemeRegistry();
if (registry == null) {
this.log.debug("Auth scheme registry not set in the context");
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java Sun May 24 14:24:26 2015
@@ -71,7 +71,7 @@ public class BasicAuthCache implements A
*/
public BasicAuthCache(final SchemePortResolver schemePortResolver) {
super();
- this.map = new ConcurrentHashMap<HttpHost, byte[]>();
+ this.map = new ConcurrentHashMap<>();
this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
DefaultSchemePortResolver.INSTANCE;
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java Sun May 24 14:24:26 2015
@@ -55,7 +55,7 @@ public class BasicCookieStore implements
public BasicCookieStore() {
super();
- this.cookies = new TreeSet<Cookie>(new CookieIdentityComparator());
+ this.cookies = new TreeSet<>(new CookieIdentityComparator());
}
/**
@@ -106,7 +106,7 @@ public class BasicCookieStore implements
@Override
public synchronized List<Cookie> getCookies() {
//create defensive copy so it won't be concurrently modified
- return new ArrayList<Cookie>(cookies);
+ return new ArrayList<>(cookies);
}
/**
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java Sun May 24 14:24:26 2015
@@ -50,7 +50,7 @@ public class BasicCredentialsProvider im
*/
public BasicCredentialsProvider() {
super();
- this.credMap = new ConcurrentHashMap<AuthScope, Credentials>();
+ this.credMap = new ConcurrentHashMap<>();
}
@Override
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java Sun May 24 14:24:26 2015
@@ -80,7 +80,7 @@ public class DefaultHttpRequestRetryHand
super();
this.retryCount = retryCount;
this.requestSentRetryEnabled = requestSentRetryEnabled;
- this.nonRetriableClasses = new HashSet<Class<? extends IOException>>();
+ this.nonRetriableClasses = new HashSet<>();
for (final Class<? extends IOException> clazz: clazzes) {
this.nonRetriableClasses.add(clazz);
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java Sun May 24 14:24:26 2015
@@ -113,10 +113,10 @@ public class FutureRequestExecutionServi
throw new IllegalStateException("Close has been called on this httpclient instance.");
}
metrics.getScheduledConnections().incrementAndGet();
- final HttpRequestTaskCallable<T> callable = new HttpRequestTaskCallable<T>(
- httpclient, request, context, responseHandler, callback, metrics);
- final HttpRequestFutureTask<T> httpRequestFutureTask = new HttpRequestFutureTask<T>(
- request, callable);
+ final HttpRequestTaskCallable<T> callable = new HttpRequestTaskCallable<>(
+ httpclient, request, context, responseHandler, callback, metrics);
+ final HttpRequestFutureTask<T> httpRequestFutureTask = new HttpRequestFutureTask<>(
+ request, callable);
executorService.execute(httpRequestFutureTask);
return httpRequestFutureTask;
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java Sun May 24 14:24:26 2015
@@ -480,7 +480,7 @@ public class HttpClientBuilder {
return this;
}
if (responseFirst == null) {
- responseFirst = new LinkedList<HttpResponseInterceptor>();
+ responseFirst = new LinkedList<>();
}
responseFirst.addFirst(itcp);
return this;
@@ -498,7 +498,7 @@ public class HttpClientBuilder {
return this;
}
if (responseLast == null) {
- responseLast = new LinkedList<HttpResponseInterceptor>();
+ responseLast = new LinkedList<>();
}
responseLast.addLast(itcp);
return this;
@@ -515,7 +515,7 @@ public class HttpClientBuilder {
return this;
}
if (requestFirst == null) {
- requestFirst = new LinkedList<HttpRequestInterceptor>();
+ requestFirst = new LinkedList<>();
}
requestFirst.addFirst(itcp);
return this;
@@ -532,7 +532,7 @@ public class HttpClientBuilder {
return this;
}
if (requestLast == null) {
- requestLast = new LinkedList<HttpRequestInterceptor>();
+ requestLast = new LinkedList<>();
}
requestLast.addLast(itcp);
return this;
@@ -845,7 +845,7 @@ public class HttpClientBuilder {
return;
}
if (closeables == null) {
- closeables = new ArrayList<Closeable>();
+ closeables = new ArrayList<>();
}
closeables.add(closeable);
}
@@ -1013,7 +1013,7 @@ public class HttpClientBuilder {
}
if (!contentCompressionDisabled) {
if (contentDecoderMap != null) {
- final List<String> encodings = new ArrayList<String>(contentDecoderMap.keySet());
+ final List<String> encodings = new ArrayList<>(contentDecoderMap.keySet());
Collections.sort(encodings);
b.add(new RequestAcceptEncoding(encodings));
} else {
@@ -1125,10 +1125,10 @@ public class HttpClientBuilder {
}
}
- List<Closeable> closeablesCopy = closeables != null ? new ArrayList<Closeable>(closeables) : null;
+ List<Closeable> closeablesCopy = closeables != null ? new ArrayList<>(closeables) : null;
if (!this.connManagerShared) {
if (closeablesCopy == null) {
- closeablesCopy = new ArrayList<Closeable>(1);
+ closeablesCopy = new ArrayList<>(1);
}
final HttpClientConnectionManager cm = connManagerCopy;
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java Sun May 24 14:24:26 2015
@@ -51,8 +51,8 @@ public class RedirectLocations extends A
public RedirectLocations() {
super();
- this.unique = new HashSet<URI>();
- this.all = new ArrayList<URI>();
+ this.unique = new HashSet<>();
+ this.all = new ArrayList<>();
}
/**
@@ -95,7 +95,7 @@ public class RedirectLocations extends A
* @since 4.1
*/
public List<URI> getAll() {
- return new ArrayList<URI>(this.all);
+ return new ArrayList<>(this.all);
}
/**
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java Sun May 24 14:24:26 2015
@@ -55,7 +55,7 @@ public class StandardHttpRequestRetryHan
*/
public StandardHttpRequestRetryHandler(final int retryCount, final boolean requestSentRetryEnabled) {
super(retryCount, requestSentRetryEnabled);
- this.idempotentMethods = new ConcurrentHashMap<String, Boolean>();
+ this.idempotentMethods = new ConcurrentHashMap<>();
this.idempotentMethods.put("GET", Boolean.TRUE);
this.idempotentMethods.put("HEAD", Boolean.TRUE);
this.idempotentMethods.put("PUT", Boolean.TRUE);
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java Sun May 24 14:24:26 2015
@@ -54,7 +54,7 @@ public class SystemDefaultCredentialsPro
private static final Map<String, String> SCHEME_MAP;
static {
- SCHEME_MAP = new ConcurrentHashMap<String, String>();
+ SCHEME_MAP = new ConcurrentHashMap<>();
SCHEME_MAP.put(AuthSchemes.BASIC.toUpperCase(Locale.ROOT), "Basic");
SCHEME_MAP.put(AuthSchemes.DIGEST.toUpperCase(Locale.ROOT), "Digest");
SCHEME_MAP.put(AuthSchemes.NTLM.toUpperCase(Locale.ROOT), "NTLM");
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java Sun May 24 14:24:26 2015
@@ -77,7 +77,7 @@ public class DefaultManagedHttpClientCon
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.id = id;
- this.attributes = new ConcurrentHashMap<String, Object>();
+ this.attributes = new ConcurrentHashMap<>();
}
public DefaultManagedHttpClientConnection(
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java Sun May 24 14:24:26 2015
@@ -58,7 +58,7 @@ public class InMemoryDnsResolver impleme
* collection held in-memory.
*/
public InMemoryDnsResolver() {
- dnsMap = new ConcurrentHashMap<String, InetAddress[]>();
+ dnsMap = new ConcurrentHashMap<>();
}
/**
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java Sun May 24 14:24:26 2015
@@ -521,8 +521,8 @@ public class PoolingHttpClientConnection
ConfigData() {
super();
- this.socketConfigMap = new ConcurrentHashMap<HttpHost, SocketConfig>();
- this.connectionConfigMap = new ConcurrentHashMap<HttpHost, ConnectionConfig>();
+ this.socketConfigMap = new ConcurrentHashMap<>();
+ this.connectionConfigMap = new ConcurrentHashMap<>();
}
public SocketConfig getDefaultSocketConfig() {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java Sun May 24 14:24:26 2015
@@ -59,7 +59,7 @@ public abstract class AbstractCookieSpec
* */
public AbstractCookieSpec() {
super();
- this.attribHandlerMap = new ConcurrentHashMap<String, CookieAttributeHandler>(10);
+ this.attribHandlerMap = new ConcurrentHashMap<>(10);
}
/**
@@ -68,7 +68,7 @@ public abstract class AbstractCookieSpec
protected AbstractCookieSpec(final HashMap<String, CookieAttributeHandler> map) {
super();
Asserts.notNull(map, "Attribute handler map");
- this.attribHandlerMap = new ConcurrentHashMap<String, CookieAttributeHandler>(map);
+ this.attribHandlerMap = new ConcurrentHashMap<>(map);
}
/**
@@ -76,7 +76,7 @@ public abstract class AbstractCookieSpec
*/
protected AbstractCookieSpec(final CommonCookieAttributeHandler... handlers) {
super();
- this.attribHandlerMap = new ConcurrentHashMap<String, CookieAttributeHandler>(handlers.length);
+ this.attribHandlerMap = new ConcurrentHashMap<>(handlers.length);
for (CommonCookieAttributeHandler handler: handlers) {
this.attribHandlerMap.put(handler.getAttributeName(), handler);
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java Sun May 24 14:24:26 2015
@@ -58,7 +58,7 @@ public class BasicClientCookie implement
super();
Args.notNull(name, "Name");
this.name = name;
- this.attribs = new HashMap<String, String>();
+ this.attribs = new HashMap<>();
this.value = value;
}
@@ -342,7 +342,7 @@ public class BasicClientCookie implement
@Override
public Object clone() throws CloneNotSupportedException {
final BasicClientCookie clone = (BasicClientCookie) super.clone();
- clone.attribs = new HashMap<String, String>(this.attribs);
+ clone.attribs = new HashMap<>(this.attribs);
return clone;
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java?rev=1681461&r1=1681460&r2=1681461&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java Sun May 24 14:24:26 2015
@@ -87,7 +87,7 @@ public abstract class CookieSpecBase ext
protected List<Cookie> parse(final HeaderElement[] elems, final CookieOrigin origin)
throws MalformedCookieException {
- final List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
+ final List<Cookie> cookies = new ArrayList<>(elems.length);
for (final HeaderElement headerelement : elems) {
final String name = headerelement.getName();
final String value = headerelement.getValue();