grpc-java icon indicating copy to clipboard operation
grpc-java copied to clipboard

NPE in ProxyDetectorImpl

Open pongad opened this issue 8 years ago • 2 comments

What version of gRPC are you using?

1.12.0

What did you expect to see?

A customer using google-cloud-java reported seeing NPEs around the time their RPCs time out. According to the customer, this happens even though they are not using a proxy.

java.lang.NullPointerException
   at io.grpc.internal.ProxyDetectorImpl.detectProxy(ProxyDetectorImpl.java:225)
   at io.grpc.internal.ProxyDetectorImpl.proxyFor(ProxyDetectorImpl.java:194)
   at io.grpc.internal.DnsNameResolver$1.run(DnsNameResolver.java:180)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
   at java.lang.Thread.run(Thread.java:811)

pongad avatar Jul 24 '18 22:07 pongad

It looks like this is the origin of the null:

    static {
        try {
            Class<?> c = Class.forName("sun.net.spi.DefaultProxySelector");
            if (c != null && ProxySelector.class.isAssignableFrom(c)) {
                theProxySelector = (ProxySelector) c.newInstance();
            }
        } catch (Exception e) {
            theProxySelector = null;
        }
    }

It seems the exception is swallowed. Is it possible they are running with a Security Manager? Also, would it be possible to set a breakpoint in java.net.ProxySelector.<clinit> and see what the exception is?

carl-mastrangelo avatar Jul 24 '18 22:07 carl-mastrangelo

CC @zpencer

ejona86 avatar Aug 07 '18 17:08 ejona86