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

getResponseCode() throws IllegalArgumentException caused by protocol error while following redirect

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 14
    • core-libs
    • None
    • behavioral
    • minimal
    • No behavior change
    • Java API
    • SE

      Summary

      java.net.ProxySelector::select needs to define all situations where IllegalArgumentException is thrown.

      Problem

      The default JDK implementation of ProxySelector throws an IAE if the URI provided has an empty protocol or host field, or if the URI itself is null. However, it is only documented to do this in case of null URI. The apidoc needs to be updated to reflect the current (correct) behavior.

      Solution

      Update to ProxySelector apidoc as per spec below. No behavior change.

      Specification

      diff -r de0ccdc4db13 src/java.base/share/classes/java/net/ProxySelector.java
      --- a/src/java.base/share/classes/java/net/ProxySelector.java   Thu Aug 22 15:52:03 2019 +0200
      +++ b/src/java.base/share/classes/java/net/ProxySelector.java   Thu Aug 22 15:34:29 2019 +0100
      @@ -1,5 +1,5 @@
       /*
      - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
      + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
        * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
        *
        * This code is free software; you can redistribute it and/or modify it
      @@ -143,7 +143,9 @@
            *          contain one element of type
            *          {@link java.net.Proxy Proxy}
            *          that represents a direct connection.
      -     * @throws IllegalArgumentException if the argument is null
      +     * @throws IllegalArgumentException if the argument is null or if
      +     *         the protocol or host cannot be determined from the provided
      +     *         {@code uri}
            */
           public abstract List<Proxy> select(URI uri);

            michaelm Michael McMahon
            webbuggrp Webbug Group
            Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: