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

Aleksey Shipilev shade at openjdk.java.net
Fri Mar 12 09:28:19 UTC 2021


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.

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

Commit messages:
 - 8263497: Clean up sun.security.krb5.PrincipalName::toByteArray

Changes: https://git.openjdk.java.net/jdk/pull/2962/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2962&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8263497
  Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2962.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2962/head:pull/2962

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


More information about the security-dev mailing list