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

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

XMLWordPrintable

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

      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.

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

              Created:
              Updated:
              Resolved: