rajinisivaram commented on code in PR #14440:
URL: https://github.com/apache/kafka/pull/14440#discussion_r1335740613


##########
clients/src/test/java/org/apache/kafka/test/TestSslUtils.java:
##########
@@ -399,10 +399,12 @@ public CertificateBuilder(int days, String algorithm) {
         }
 
         public CertificateBuilder sanDnsNames(String... hostNames) throws 
IOException {
-            GeneralName[] altNames = new GeneralName[hostNames.length];
-            for (int i = 0; i < hostNames.length; i++)
-                altNames[i] = new GeneralName(GeneralName.dNSName, 
hostNames[i]);
-            subjectAltName = GeneralNames.getInstance(new 
DERSequence(altNames)).getEncoded();
+            if (hostNames.length > 0) {
+                GeneralName[] altNames = new GeneralName[hostNames.length];
+                for (int i = 0; i < hostNames.length; i++)
+                    altNames[i] = new GeneralName(GeneralName.dNSName, 
hostNames[i]);
+                subjectAltName = GeneralNames.getInstance(new 
DERSequence(altNames)).getEncoded();
+            }

Review Comment:
   Should we also add an `else` clause that sets `subjectAltName = null` to 
preserve the override semantics if the method is called twice? Just in case 
some test relies on overriding existing hostname in future.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to