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

Refactor I/O stream copying to use InputStream.readAllBytes in X509CertPath

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P5
    • 20
    • None
    • security-libs

    Description

      There is method sun.security.provider.certpath.X509CertPath#readAllBytes which does reading all bytes from an InputStream

          private static byte[] readAllBytes(InputStream is) throws IOException {
              byte[] buffer = new byte[8192];
              ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
              int n;
              while ((n = is.read(buffer)) != -1) {
                  baos.write(buffer, 0, n);
              }
              return baos.toByteArray();
          }

      Since Java 9 we have a handy method java.io.InputStream#readAllBytes which could be used instead.

      Attachments

        Issue Links

          Activity

            People

              aturbanov Andrey Turbanov
              aturbanov Andrey Turbanov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: