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

CSS StyleManager has poor performance due to unbuffered input stream

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • jfx11, 8, jfx16
    • javafx

      The StyleManager::calculateCheckSum method calculates a checksum using a MessageDigest read from an InputStream obtained from the URL of the stylesheet. The problem is that it reads bytes from the stream one byte at a time without wrapping the InputStream in a BufferedStream:

                      try (final InputStream stream = url.openStream();
                          final DigestInputStream dis = new DigestInputStream(stream, MessageDigest.getInstance("MD5")); ) {
                          dis.getMessageDigest().reset();
                          while (dis.read() != -1) { /* empty loop body is intentional */ }
                          return dis.getMessageDigest().digest();
                      }

      It should either wrap the original stream in a BufferedInputStream or else read an array of, say 4K, bytes using the read(byte[]) method. The latter approach is used by the NativeLibLoader::cacheLibrary method.

            arapte Ambarish Rapte
            kcr Kevin Rushforth
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: