URLConnection.getRequestProperties() doesn't throw as promised

Michael McMahon michael.x.mcmahon at oracle.com
Thu May 20 23:15:45 PDT 2010


Martin Buchholz wrote:
> Hi net-dev gang,
>
> A colleague reports that:
>
> URLConnection.getRequestProperties() promises to throw an
> IllegalStateException when invoked on a connected instance. But Java 6
> returns a valid map.
>
> Can you get either the spec or the implementation fixed so that the two agree?
>
> Thanks,
>
> Martin
>   
I checked this and I agree that when a HttpURLConnection is connected,
ISE is thrown when you call getRequestProperties(). Then, after you call
disconnect(), getRequestProperties() returns a valid map.

This probably wasn't the intended behavior, but I don't think there is 
any upside
in changing it, given the potential for breaking running code.

I propose we change the spec. to be compatible with the current behavior.

- Michael.



More information about the net-dev mailing list