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 2017/05/09 19:58:37 UTC
[45/50] [abbrv] httpcomponents-core git commit: Use
try-with-resources. Fix Checkstyle in Javadocs.
Use try-with-resources. Fix Checkstyle in Javadocs.
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk@1793825 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/f392d690
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/f392d690
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/f392d690
Branch: refs/heads/trunk
Commit: f392d69048c6ff624398d53d930eb4d93fe5b931
Parents: bc75d33
Author: Gary D. Gregory <gg...@apache.org>
Authored: Thu May 4 15:28:08 2017 +0000
Committer: Gary D. Gregory <gg...@apache.org>
Committed: Thu May 4 15:28:08 2017 +0000
----------------------------------------------------------------------
.../apache/hc/core5/ssl/SSLContextBuilder.java | 22 +++++---------------
1 file changed, 5 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f392d690/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
index 4300ac7..d06d526 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
@@ -96,7 +96,7 @@ public class SSLContextBuilder {
/**
* Sets the SSLContext algorithm name.
- *
+ *
* @param protocol
* the SSLContext algorithm name of the requested protocol. See
* the SSLContext section in the <a href=
@@ -158,11 +158,8 @@ public class SSLContextBuilder {
final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
Args.notNull(file, "Truststore file");
final KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
- final FileInputStream instream = new FileInputStream(file);
- try {
+ try (final FileInputStream instream = new FileInputStream(file)) {
trustStore.load(instream, storePassword);
- } finally {
- instream.close();
}
return loadTrustMaterial(trustStore, trustStrategy);
}
@@ -184,11 +181,8 @@ public class SSLContextBuilder {
final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
Args.notNull(url, "Truststore URL");
final KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
- final InputStream instream = url.openStream();
- try {
+ try (final InputStream instream = url.openStream()) {
trustStore.load(instream, storePassword);
- } finally {
- instream.close();
}
return loadTrustMaterial(trustStore, trustStrategy);
}
@@ -237,11 +231,8 @@ public class SSLContextBuilder {
final PrivateKeyStrategy aliasStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException {
Args.notNull(file, "Keystore file");
final KeyStore identityStore = KeyStore.getInstance(KeyStore.getDefaultType());
- final FileInputStream instream = new FileInputStream(file);
- try {
+ try (final FileInputStream instream = new FileInputStream(file)) {
identityStore.load(instream, storePassword);
- } finally {
- instream.close();
}
return loadKeyMaterial(identityStore, keyPassword, aliasStrategy);
}
@@ -260,11 +251,8 @@ public class SSLContextBuilder {
final PrivateKeyStrategy aliasStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException {
Args.notNull(url, "Keystore URL");
final KeyStore identityStore = KeyStore.getInstance(KeyStore.getDefaultType());
- final InputStream instream = url.openStream();
- try {
+ try (final InputStream instream = url.openStream()) {
identityStore.load(instream, storePassword);
- } finally {
- instream.close();
}
return loadKeyMaterial(identityStore, keyPassword, aliasStrategy);
}