Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8263497

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

    XMLWordPrintable

Details

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              shade Aleksey Shipilev
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: