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

HttpsURLConnection: Remove the IOException from the constructor

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 5.0
    • Component/s: security-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b40
    • CPU:
      sparc
    • OS:
      solaris_7
    • Verification:
      Verified

      Description

      Name: mtR10145 Date: 01/13/2004

      The spec of HttpsURLConnection(URLáurl) states:

      Throws: IOException - if the connection can't be established

      However, this constructor does not throw IOException for null
      argument. Test code below illustrates this bug.
      =================== Test24.java =========================
      import javax.net.ssl.*;
      import java.security.cert.Certificate;
      import java.net.URL;
      import java.io.IOException;

      public class Test24 {

          public static void main(String argv[]) {
              Test24 test = new Test24();
              test.go();
          }

          public void go() {
              try {
                  HttpsURLConnection c = (HttpsURLConnection) new MyHttpsURLConnection((URL) null);
                  System.out.println("Error: expected exception not thrown");
              } catch (IOException ioe) {
                  System.out.println("Passed");
              } catch (NullPointerException npe) {
                  System.out.println("Error: unspecified NPE thrown: " + npe);
              }
          }


      class MyHttpsURLConnection extends HttpsURLConnection {
          public MyHttpsURLConnection(URL url) throws IOException {
              super(url);
          }

          public String getCipherSuite() {
              return new String("");
          }

          public Certificate[] getLocalCertificates() {
              return null;
          }

          public Certificate[] getServerCertificates() {
              return null;
          }

          public boolean usingProxy() {
              return false;
          }

          public void connect() {
          }

          public void disconnect() {
          }
      }
      }
      =================== output (build 1.5.0-beta-b32 =============
      Error: expected exception not thrown
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              wetmore Bradford Wetmore
              Reporter:
              cmssunw Cms Cms (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: