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

Aleksey Shipilev shade at openjdk.java.net
Mon Mar 15 06:31:08 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.

This pull request has now been integrated.

Changeset: 06383033
Author:    Aleksey Shipilev <shade at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/06383033
Stats:     2 lines in 1 file changed: 0 ins; 1 del; 1 mod

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

Reviewed-by: weijun

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

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



More information about the security-dev mailing list