6868867: Test: sun/security/tools/keytool/standard.sh fails under windows/cygwin
authorweijun
Tue, 11 Aug 2009 15:36:52 +0800
changeset 3484 df231966aa41
parent 3483 a16fce1820ef
child 3485 bc05765c365a
6868867: Test: sun/security/tools/keytool/standard.sh fails under windows/cygwin Reviewed-by: wetmore
jdk/src/share/classes/sun/security/tools/KeyTool.java
--- a/jdk/src/share/classes/sun/security/tools/KeyTool.java	Tue Aug 11 12:20:32 2009 +0800
+++ b/jdk/src/share/classes/sun/security/tools/KeyTool.java	Tue Aug 11 15:36:52 2009 +0800
@@ -880,41 +880,41 @@
             // might not work properly, since -gencert is slow
             // and there's no data in the pipe at the beginning.
             ByteArrayOutputStream bout = new ByteArrayOutputStream();
-            byte[] b = new byte[4096];
-            while (true) {
-                int len = inStream.read(b);
-                if (len < 0) break;
-                bout.write(b, 0, len);
-            }
-            inStream = new ByteArrayInputStream(bout.toByteArray());
             try {
-                String importAlias = (alias!=null)?alias:keyAlias;
-                if (keyStore.entryInstanceOf(importAlias, KeyStore.PrivateKeyEntry.class)) {
-                    kssave = installReply(importAlias, inStream);
-                    if (kssave) {
-                        System.err.println(rb.getString
-                            ("Certificate reply was installed in keystore"));
-                    } else {
-                        System.err.println(rb.getString
-                            ("Certificate reply was not installed in keystore"));
-                    }
-                } else if (!keyStore.containsAlias(importAlias) ||
-                        keyStore.entryInstanceOf(importAlias,
-                            KeyStore.TrustedCertificateEntry.class)) {
-                    kssave = addTrustedCert(importAlias, inStream);
-                    if (kssave) {
-                        System.err.println(rb.getString
-                            ("Certificate was added to keystore"));
-                    } else {
-                        System.err.println(rb.getString
-                            ("Certificate was not added to keystore"));
-                    }
+                byte[] b = new byte[4096];
+                while (true) {
+                    int len = inStream.read(b);
+                    if (len < 0) break;
+                    bout.write(b, 0, len);
                 }
             } finally {
                 if (inStream != System.in) {
                     inStream.close();
                 }
             }
+            inStream = new ByteArrayInputStream(bout.toByteArray());
+            String importAlias = (alias!=null)?alias:keyAlias;
+            if (keyStore.entryInstanceOf(importAlias, KeyStore.PrivateKeyEntry.class)) {
+                kssave = installReply(importAlias, inStream);
+                if (kssave) {
+                    System.err.println(rb.getString
+                        ("Certificate reply was installed in keystore"));
+                } else {
+                    System.err.println(rb.getString
+                        ("Certificate reply was not installed in keystore"));
+                }
+            } else if (!keyStore.containsAlias(importAlias) ||
+                    keyStore.entryInstanceOf(importAlias,
+                        KeyStore.TrustedCertificateEntry.class)) {
+                kssave = addTrustedCert(importAlias, inStream);
+                if (kssave) {
+                    System.err.println(rb.getString
+                        ("Certificate was added to keystore"));
+                } else {
+                    System.err.println(rb.getString
+                        ("Certificate was not added to keystore"));
+                }
+            }
         } else if (command == IMPORTKEYSTORE) {
             doImportKeyStore();
             kssave = true;