Comment 5 for bug 885195

Revision history for this message
Sebastien Bigaret (sebastien-bigaret-f) wrote :

Attached is a simple wrapper that can be used to replace the default proxy selector, to eliminate the random crashes.

How to use: simply replace the default proxy selector as soon as possible in your application code:

    ProxySelector defaultProxySelector = ProxySelector.getDefault();
    if (defaultProxySelector!=null)
        ProxySelector.setDefault(new ProxySelectorWrapper(defaultProxySelector));

Details: making the select() method synchronized eliminates the possibility to concurrently access the MT-unsafe 'gconf_client' which is used in the native method sun.net.spi.DefaultProxySelector.getSystemProxy() (which in turn is called by DefaultProxySelector.select() when property java.net.useSystemProxies is set to true).

See:
- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7188755
- http://mail.openjdk.java.net/pipermail/jdk7u-dev/2012-August/003911.html
- openjdk/jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c
- openjdk/jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java