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

Expensive fillInStackTrace operation in HttpURLConnection.getLastModified when no last-modified in response

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 21
    • 17, 20, 21
    • core-libs
    • b12

      In the method java.net.HttpURLConnection#getHeaderFieldDate

          public long getHeaderFieldDate(String name, long Default) {
              String dateString = getHeaderField(name);
              try {
                  if (!dateString.contains("GMT")) {
                      dateString = dateString+" GMT";
                  }
                  return Date.parse(dateString);
              } catch (Exception e) {
              }
              return Default;
          }

      If dateString, expensive NPE is thrown and then caught.
      For example it happen with 'last-modified' header.
      We should check whether it is present before trying to parse it.

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

              Created:
              Updated:
              Resolved: