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

URL.openStream() is an extremely slow

    Details

    • Type: Bug
    • Status: Open
    • Priority: P5
    • Resolution: Unresolved
    • Affects Version/s: 13
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:

      Description

      While working on JDK-8202177 I found that URL.openStream() might be very slow, and looks like it does not necessary depend on the network performance.

      I have tested it on macOS using this program:

      public final class URLOpenStream {

          public static void main(final String[] args) throws Exception {
              connect("https://bugs.openjdk.java.net");
          }

          private static void connect(final String path) throws IOException {
              URL url = new URL(path);
              for (int i = 0; i < 3; ++i) {
                  long start = System.currentTimeMillis();
                  InputStream is = url.openStream();
                  long end = System.currentTimeMillis();

                  System.out.println("connect in " + (end - start) + "ms");
                  is.close();
              }
          }
      }
      ===========
      Output:
      connect in 1216ms
      connect in 275ms
      connect in 233ms

      Sometimes initial time is dropped to a few seconds. And initial submitter reports tens of seconds.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                chegar Chris Hegarty
                Reporter:
                serb Sergey Bylokhov
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: