<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">FYI updated webrev at:<div class="">  <a href="http://cr.openjdk.java.net/~vinnie/8079129/webrev.01/" class="">http://cr.openjdk.java.net/~vinnie/8079129/webrev.01/</a></div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 5 May 2015, at 15:53, Vincent Ryan <<a href="mailto:vincent.x.ryan@oracle.com" class="">vincent.x.ryan@oracle.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Iíll skip the initialization.<br class="">Thanks.<br class=""><br class=""><br class=""><blockquote type="cite" class="">On 5 May 2015, at 15:52, Weijun Wang <<a href="mailto:weijun.wang@oracle.com" class="">weijun.wang@oracle.com</a>> wrote:<br class=""><br class="">That's good, but there is no need to assign null in<br class=""><br class="">      Certificate[] certs = null;<br class=""><br class="">Or, maybe you can add "if (certs != null)" around the loop, but you might not like an extra indentation.<br class=""><br class="">--Max<br class=""><br class="">On 5/5/2015 10:44 PM, Vincent Ryan wrote:<br class=""><blockquote type="cite" class="">OK. How about this?<br class=""><br class="">--- a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java<br class="">+++ b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java<br class="">@@ -1,5 +1,5 @@<br class=""> /*<br class="">- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights<br class="">reserved.<br class="">+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights<br class="">reserved.<br class="">  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.<br class="">  *<br class="">  * This code is free software; you can redistribute it and/or modify it<br class="">@@ -1642,23 +1642,22 @@<br class="">             Entry entry = entries.get(alias);<br class=""><br class=""><br class="">             // certificate chain<br class="">-            int chainLen = 1;<br class="">             Certificate[] certs = null;<br class=""><br class=""><br class="">             if (entry instanceof PrivateKeyEntry) {<br class="">                 PrivateKeyEntry keyEntry = (PrivateKeyEntry) entry;<br class="">-                    if (keyEntry.chain == null) {<br class="">-                        chainLen = 0;<br class="">-                    } else {<br class="">-                        chainLen = keyEntry.chain.length;<br class="">-                    }<br class="">-                certs = keyEntry.chain;<br class="">-<br class="">+                if (keyEntry.chain != null) {<br class="">+                    certs = keyEntry.chain;<br class="">+                } else {<br class="">+                    certs = new Certificate[0];<br class="">+                }<br class="">             } else if (entry instanceof CertEntry) {<br class="">-               certs = new Certificate[]{((CertEntry) entry).cert};<br class="">+                certs = new Certificate[]{((CertEntry) entry).cert};<br class="">+            } else {<br class="">+                certs = new Certificate[0];<br class="">             }<br class=""><br class=""><br class="">-            for (int i = 0; i < chainLen; i++) {<br class="">+            for (int i = 0; i < certs.length; i++) {<br class="">                 // create SafeBag of Type CertBag<br class="">                 DerOutputStream safeBag = new DerOutputStream();<br class="">                 safeBag.putOID(CertBag_OID);<br class=""><br class=""><br class=""><br class=""><blockquote type="cite" class="">On 5 May 2015, at 15:10, Weijun Wang <<a href="mailto:weijun.wang@oracle.com" class="">weijun.wang@oracle.com</a><br class=""><<a href="mailto:weijun.wang@oracle.com" class="">mailto:weijun.wang@oracle.com</a>>> wrote:<br class=""><br class="">Anyway it looks redundant and error-prone to maintain the length of an<br class="">array in a separate variable.<br class=""><br class="">--Max<br class=""><br class="">On 5/5/2015 8:32 PM, Vincent Ryan wrote:<br class=""><blockquote type="cite" class="">Replacing the for loop below with a for-each loop on certs would be<br class="">fine except that certs can be null.<br class="">I could initialize certs with an empty array on each iteration of the<br class="">outer loop but it doesnít seem to gain much overall.<br class=""><br class=""><br class=""><blockquote type="cite" class="">On 4 May 2015, at 13:10, Weijun Wang <<a href="mailto:weijun.wang@oracle.com" class="">weijun.wang@oracle.com</a><br class=""><<a href="mailto:weijun.wang@oracle.com" class="">mailto:weijun.wang@oracle.com</a>>> wrote:<br class=""><br class="">1662             for (int i = 0; i < chainLen; i++) {<br class=""><br class=""><br class="">On 5/4/2015 6:08 PM, Vincent Ryan wrote:<br class=""><blockquote type="cite" class="">Which line?<br class=""><br class=""><blockquote type="cite" class="">On 2 May 2015, at 02:22, Weijun Wang <<a href="mailto:weijun.wang@oracle.com" class="">weijun.wang@oracle.com</a><br class=""><<a href="mailto:weijun.wang@oracle.com" class="">mailto:weijun.wang@oracle.com</a>>> wrote:<br class=""><br class="">Is it safe to just run for-each on certs (if it's not null)?<br class=""><br class="">--Max<br class=""><br class="">On 5/2/2015 6:39 AM, Vincent Ryan wrote:<br class=""><blockquote type="cite" class="">Please review this fix to correct the PKCS12 encoding when a<br class="">secret key is being stored in one keystore entry and a<br class="">certificate in another.<br class=""><br class="">Thanks.<br class=""><br class=""><br class="">Bug: <a href="https://bugs.openjdk.java.net/browse/JDK-8079129" class="">https://bugs.openjdk.java.net/browse/JDK-8079129</a><br class="">Webrev: <a href="http://cr.openjdk.java.net/~vinnie/8079129/webrev.00/" class="">http://cr.openjdk.java.net/~vinnie/8079129/webrev.00/</a><br class=""><br class=""></blockquote></blockquote><br class=""></blockquote></blockquote><br class=""></blockquote></blockquote><br class=""></blockquote></blockquote><br class=""></div></blockquote></div><br class=""></div></body></html>