question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPE Crash At java.net.Proxy.type()

See original GitHub issue

okhttp3 Version: 3.10.0 Device/Android Version: vivo 1719;Android 7.1.2,level 25 Redmi Note 3;Android 8.1.0,level 27 SM-G570Y;Android 7.0,level 24

Crash Report:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.net.Proxy$Type java.net.Proxy.type()' on a null object reference 
okhttp3.internal.http.RetryAndFollowUpInterceptor.okhttp3.Request followUpRequest(okhttp3.Response,okhttp3.Route)(SourceFile:282) 
okhttp3.internal.http.RetryAndFollowUpInterceptor.okhttp3.Response intercept(okhttp3.Interceptor$Chain)(SourceFile:158) 
okhttp3.internal.http.RealInterceptorChain.okhttp3.Response proceed(okhttp3.Request,okhttp3.internal.connection.StreamAllocation,okhttp3.internal.http.HttpCodec,okhttp3.internal.connection.RealConnection)(SourceFile:147) 
okhttp3.internal.http.RealInterceptorChain.okhttp3.Response proceed(okhttp3.Request)(SourceFile:121) 
okhttp3.RealCall.okhttp3.Response getResponseWithInterceptorChain()(SourceFile:200) 
okhttp3.RealCall$AsyncCall.void execute()(SourceFile:147) 
okhttp3.internal.NamedRunnable.void run()(SourceFile:32) 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
java.lang.Thread.run(Thread.java:818) 

the case almost is same like #3809,but I wonder why it returns null Proxy(eg below code shown) and how do solve it? code fo resulting in crash.

private Request followUpRequest(Response userResponse, Route route) throws IOException {
    .............
    switch (responseCode) {
      case HTTP_PROXY_AUTH:
        Proxy selectedProxy = route != null
            ? route.proxy()
            : client.proxy();
        if (selectedProxy.type() != Proxy.Type.HTTP) {
          throw new ProtocolException("Received HTTP_PROXY_AUTH (407) code while not using proxy");
        }
        return client.proxyAuthenticator().authenticate(route, userResponse);
      ........
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
bingxuebagecommented, Jun 25, 2018

I meet this bug

Read more comments on GitHub >

github_iconTop Results From Across the Web

Project runs in IDE but the JAR file does not execute due to ...
In order for it to run in it's current environment, it needs to use the browser's proxy settings. When I build the project...
Read more >
NPE on ExceptionBean when processing SOAP Fault
JDK-8190836 : NPE on ExceptionBean when processing SOAP Fault. Type: Bug; Component: xml; Sub-Component: jaxb; Affected Version: 7u161.
Read more >
java.net.Proxy.type java code examples - Tabnine
Returns true if this route tunnels HTTPS through an HTTP proxy. See <a * href="http://www.ietf.org/rfc/rfc2817.txt">RFC 2817, Section 5.2</a>.
Read more >
202406 – NPE on start IDE
Issue Type: DEFECT ... getPluggedInAuthenticator(ProxyManager.java:390) at ... Activator.start() of bundle org.eclipse.core.net. at ...
Read more >
BottomNavigationView crashes with NPE when adding menu ...
MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.support.v7.view.menu.MenuBuilder.size()' on a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found