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

NPE in HttpsURLConnectionImpl.getResponseCode

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      1.8.0_111-b14, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 64-Bit

      A DESCRIPTION OF THE PROBLEM :
      This is an upstream bug report from:
      https://josm.openstreetmap.de/ticket/13964

      When calling HttpsURLConnectionImpl.getResponseCode() it is possible to face an NPE with this stacktrace:

      === STACK TRACE ===
      Thread: AWT-EventQueue-0 (19) of main
      java.lang.NullPointerException
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
      at java.net.HttpURLConnection.getResponseCode(Unknown Source)
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
      at org.openstreetmap.josm.tools.HttpClient.connect(HttpClient.java:126)
      at org.openstreetmap.josm.io.OsmServerReader.getInputStreamRaw(OsmServerReader.java:158)
      at org.openstreetmap.josm.io.OsmServerReader.getInputStreamRaw(OsmServerReader.java:110)
      at org.openstreetmap.josm.io.OsmServerReader.getInputStream(OsmServerReader.java:74)
      at org.openstreetmap.josm.io.OsmServerReader.getInputStream(OsmServerReader.java:57)
      at org.openstreetmap.josm.io.BoundingBoxDownloader.parseOsm(BoundingBoxDownloader.java:186)
      at org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask$DownloadTask.parseDataSet(DownloadOsmTask.java:312)
      at org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask$DownloadTask.realRun(DownloadOsmTask.java:320)
      at org.openstreetmap.josm.gui.PleaseWaitRunnable.doRealRun(PleaseWaitRunnable.java:93)
      at org.openstreetmap.josm.gui.PleaseWaitRunnable.run(PleaseWaitRunnable.java:141)
      at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)

      REPRODUCIBILITY :
      This bug can be reproduced rarely.

      ---------- BEGIN SOURCE ----------
              URL url = new URL("https://...");
              HttpURLConnection connection = (HttpURLConnection) url.openConnection();

              connection.setRequestMethod(requestMethod);
              connection.setRequestProperty("User-Agent", Version.getInstance().getFullAgentString());
              connection.setConnectTimeout(connectTimeout);
              connection.setReadTimeout(readTimeout);
              connection.setInstanceFollowRedirects(false); // we do that ourselves
              if (ifModifiedSince > 0) {
                  connection.setIfModifiedSince(ifModifiedSince);
              }
              connection.setUseCaches(useCache);
              if (!useCache) {
                  connection.setRequestProperty("Cache-Control", "no-cache");
              }
              for (Map.Entry<String, String> header : headers.entrySet()) {
                  if (header.getValue() != null) {
                      connection.setRequestProperty(header.getKey(), header.getValue());
                  }
              }
              connection.connect();
              int code = connection.getResponseCode(); // <NPE here
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: