Several issues with java.net.URLConnection

Chris Hegarty chris.hegarty at oracle.com
Tue Nov 18 11:38:20 UTC 2014



On 17/11/14 23:27, Pavel Rappo wrote:
> Hi everyone,
>
> I've been working with the URLConnection class for some time now and have noticed several interesting things.
>
> 1. Unsafe publication of java.net.URLConnection.factory static field (it looks very similar to [1])
> 2. Benign race condition in java.net.URLConnection.getContentHandler on java.net.URLConnection.handlers static field
> 3. Handlers produced by factory are not cached in the handlers field (I don't know whether it was done deliberately or not, but I couldn't find any explanation on it in the javadoc. Moreover the behaviour of the factory in the URL class is different. It caches whatever is produced by the factory there).
>
> So which of these do you think are real issues worth fixing?

1 and 2 : Yes.
3 needs a little more consideration, but my gut feeling is that we 
should do it unless there is a good reason not to.

-Chris.

> ------------------------------------------------------------
> [1] The same thing was noticed by Peter Levart here: http://mail.openjdk.java.net/pipermail/core-libs-dev/2014-July/027534.html
>
> -Pavel
>



More information about the core-libs-dev mailing list