Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException throw with null exception #3245

Closed
liujigang opened this issue Mar 28, 2017 · 12 comments
Closed

java.lang.NullPointerException throw with null exception #3245

liujigang opened this issue Mar 28, 2017 · 12 comments

Comments

@liujigang
Copy link

liujigang commented Mar 28, 2017

error stack:

1 java.net.Socket.getInputStream(Socket.java:894)
2 okio.Okio.okio.Source source(java.net.Socket)(Okio.java:220)
3 okhttp3.internal.connection.RealConnection.void connectSocket(int,int)(RealConnection.java:226)
4 okhttp3.internal.connection.RealConnection.void connect(int,int,int,boolean)(RealConnection.java:146)
5 okhttp3.internal.connection.StreamAllocation.okhttp3.internal.connection.RealConnection findConnection(int,int,int,boolean)(StreamAllocation.java:186)
6 okhttp3.internal.connection.StreamAllocation.okhttp3.internal.connection.RealConnection findHealthyConnection(int,int,int,boolean,boolean)(StreamAllocation.java:121)
7 okhttp3.internal.connection.StreamAllocation.okhttp3.internal.http.HttpCodec newStream(okhttp3.OkHttpClient,boolean)(StreamAllocation.java:100)
8 okhttp3.internal.connection.ConnectInterceptor.okhttp3.Response intercept(okhttp3.Interceptor$Chain)(ConnectInterceptor.java:42)
9 okhttp3.internal.http.RealInterceptorChain.okhttp3.Response proceed(okhttp3.Request,okhttp3.internal.connection.StreamAllocation,okhttp3.internal.http.HttpCodec,okhttp3.Connection)(RealInterceptorChain.java:92)
10 okhttp3.internal.http.RealInterceptorChain.okhttp3.Response proceed(okhttp3.Request)(RealInterceptorChain.java:67)
11 okhttp3.internal.cache.CacheInterceptor.okhttp3.Response intercept(okhttp3.Interceptor$Chain)(CacheInterceptor.java:93)
12 okhttp3.internal.http.RealInterceptorChain.okhttp3.Response proceed(okhttp3.Request,okhttp3.internal.connection.StreamAllocation,okhttp3.internal.http.HttpCodec,okhttp3.Connection)(RealInterceptorChain.java:92)
13 okhttp3.internal.http.RealInterceptorChain.okhttp3.Response proceed(okhttp3.Request)(RealInterceptorChain.java:67)
14 okhttp3.internal.http.BridgeInterceptor.okhttp3.Response intercept(okhttp3.Interceptor$Chain)(BridgeInterceptor.java:93)
15 okhttp3.internal.http.RealInterceptorChain.okhttp3.Response proceed(okhttp3.Request,okhttp3.internal.connection.StreamAllocation,okhttp3.internal.http.HttpCodec,okhttp3.Connection)(RealInterceptorChain.java:92)
16 okhttp3.internal.http.RetryAndFollowUpInterceptor.okhttp3.Response intercept(okhttp3.Interceptor$Chain)(RetryAndFollowUpInterceptor.java:120)
17 okhttp3.internal.http.RealInterceptorChain.okhttp3.Response proceed(okhttp3.Request,okhttp3.internal.connection.StreamAllocation,okhttp3.internal.http.HttpCodec,okhttp3.Connection)(RealInterceptorChain.java:92)
18 okhttp3.internal.http.RealInterceptorChain.okhttp3.Response proceed(okhttp3.Request)(RealInterceptorChain.java:67)
19 okhttp3.RealCall.okhttp3.Response getResponseWithInterceptorChain()(RealCall.java:179)
20 okhttp3.RealCall$AsyncCall.void execute()(RealCall.java:129)
21 okhttp3.internal.NamedRunnable.void run()(NamedRunnable.java:32)
22 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
23 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
24 java.lang.Thread.run(Thread.java:761)

environ: Android 7.0 samsung SM-G9350 , xiaomi mi5 Android 7.0 and other android 7.0.

okhttp3,3.6.0

@swankjesse
Copy link
Collaborator

Executable test case to reproduce the problem?

@cvance
Copy link

cvance commented Apr 3, 2017

Seeing the same exact crash for a handful of users, mostly on Samsung S7 line devices. Unfortunately I'm unable to reproduce and due to the stacktrace, not even sure where it's coming from on my side. I'll let you know if I'm able to reproduce or find the origin.

@swankjesse
Copy link
Collaborator

I think you probably want to report this to Samsung. It’s likely an issue with that device that you’ll probably see on any HTTP client.

@liujigang
Copy link
Author

2017-04-06 11-47-04

tracking this bug a week(about 2,004 user crash), most crash at huawei phone,other is samsung,xiaomi , all in android 7.0 .

@swankjesse
Copy link
Collaborator

FYI @15characterlimi

@swankjesse
Copy link
Collaborator

No action for us to take on this.

@15characterlimi
Copy link
Contributor

This is a known bug in Android 7.0; it was fixed by this change which went into Android 7.1:

https://android-review.googlesource.com/#/c/271775/

I'm very sorry that we found it too late for Android 7.0 and that you ran into it.

The issue is that Android 7.0's PrivilegedActionException.getException() returns null, so places that do:

throw privilegedActionException.getException()

will attempt to throw a null value. There are 19 such places in Android N; sadly, this is one of them. :-( I plan to take appropriate measures to make vendors aware of this issue and the patch.

@15characterlimi
Copy link
Contributor

PS. I should add that the NullPointerException from this Android bug masks some other Exception that would normally be thrown at affected places in the code. In the particular example of Socket, in cases where Socket.getInputStream() or getOutputStream() should throw IOException but the socket was still open at the start of that method being called, then the IOException will be swallowed and replaced by the NullPointerException that you have observed. :(

@swankjesse
Copy link
Collaborator

We could fix the callsite to catch NPE and rethrow an IOException. Lemme see what that looks like.

@liujigang
Copy link
Author

thanks.

@15characterlimi
Copy link
Contributor

Such a workaround could work, but should probably be specific to the kind of "throw with null exception" kind of NPE. Let me know how you go / whether you need help.

@liujigang
Copy link
Author

@15characterlimi i send email to developer@huawei.com report this bug. i think under ideal conditions this exception case by some rom, unnecessary throw null exception.

Alonexx referenced this issue in facebook/react-native Jul 10, 2017
Reviewed By: yungsters

Differential Revision: D5144011

fbshipit-source-id: ef897bf7e03b84e4e60ec6607027666608a460cb
yeriomin added a commit to yeriomin/YalpStore that referenced this issue May 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants