--- a/jdk/src/share/classes/sun/security/ssl/SSLContextImpl.java Mon Jul 18 22:25:58 2011 +0100
+++ b/jdk/src/share/classes/sun/security/ssl/SSLContextImpl.java Tue Jul 19 08:21:05 2011 -0700
@@ -567,42 +567,46 @@
}
FileInputStream fs = null;
- if (defaultKeyStore.length() != 0 && !NONE.equals(defaultKeyStore)) {
- fs = AccessController.doPrivileged(
- new PrivilegedExceptionAction<FileInputStream>() {
- public FileInputStream run() throws Exception {
- return new FileInputStream(defaultKeyStore);
- }
- });
- }
-
- String defaultKeyStorePassword = props.get("keyStorePasswd");
+ KeyStore ks = null;
char[] passwd = null;
- if (defaultKeyStorePassword.length() != 0) {
- passwd = defaultKeyStorePassword.toCharArray();
- }
+ try {
+ if (defaultKeyStore.length() != 0 &&
+ !NONE.equals(defaultKeyStore)) {
+ fs = AccessController.doPrivileged(
+ new PrivilegedExceptionAction<FileInputStream>() {
+ public FileInputStream run() throws Exception {
+ return new FileInputStream(defaultKeyStore);
+ }
+ });
+ }
- /**
- * Try to initialize key store.
- */
- KeyStore ks = null;
- if ((defaultKeyStoreType.length()) != 0) {
- if (debug != null && Debug.isOn("defaultctx")) {
- System.out.println("init keystore");
- }
- if (defaultKeyStoreProvider.length() == 0) {
- ks = KeyStore.getInstance(defaultKeyStoreType);
- } else {
- ks = KeyStore.getInstance(defaultKeyStoreType,
- defaultKeyStoreProvider);
+ String defaultKeyStorePassword = props.get("keyStorePasswd");
+ if (defaultKeyStorePassword.length() != 0) {
+ passwd = defaultKeyStorePassword.toCharArray();
}
- // if defaultKeyStore is NONE, fs will be null
- ks.load(fs, passwd);
- }
- if (fs != null) {
- fs.close();
- fs = null;
+ /**
+ * Try to initialize key store.
+ */
+ if ((defaultKeyStoreType.length()) != 0) {
+ if (debug != null && Debug.isOn("defaultctx")) {
+ System.out.println("init keystore");
+ }
+ if (defaultKeyStoreProvider.length() == 0) {
+ ks = KeyStore.getInstance(defaultKeyStoreType);
+ } else {
+ ks = KeyStore.getInstance(defaultKeyStoreType,
+ defaultKeyStoreProvider);
+ }
+
+ // if defaultKeyStore is NONE, fs will be null
+ ks.load(fs, passwd);
+ }
+ } finally {
+ if (fs != null) {
+ fs.close();
+ fs = null;
+ }
}
/*