RFR: 8263497: Clean up sun.security.krb5.PrincipalName::toByteArray

Weijun Wang weijun at openjdk.java.net
Fri Mar 12 16:13:18 UTC 2021


On Fri, 12 Mar 2021 09:22:40 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> SonarCloud actually found this:
>   Verify this is the index that was intended; it was already set before.
> 
>  
>     public byte[][] toByteArray() {
>         byte[][] result = new byte[nameStrings.length][];
>         for (int i = 0; i < nameStrings.length; i++) {
>             result[i] = new byte[nameStrings[i].length()]; // <-- here
>             result[i] = nameStrings[i].getBytes();
>         }
>         return result;
>     }
> 
> `getBytes()` returns the `byte[]` array, there is no need to allocate the array before it.

Marked as reviewed by weijun (Reviewer).

Update the copyright year to 2021 and everything else is fine. Thanks.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2962


More information about the security-dev mailing list