New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 613599 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: May 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 1
Type: Bug



Sign in to add a comment

NullPointerException in NetworkChangeNotifierAutoDetect.java

Project Member Reported by xunji...@chromium.org, May 20 2016

Issue description

Upon network change, we might encounter a NPE with the following stack trace.

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.net.NetworkInfo.getType()' on a null object reference
        at org.chromium.net.NetworkChangeNotifierAutoDetect$ConnectivityManagerDelegate.getNetworkState(NetworkChangeNotifierAutoDetect.java:97)
        at org.chromium.net.NetworkChangeNotifierAutoDetect$MyNetworkCallback.onCapabilitiesChanged(NetworkChangeNotifierAutoDetect.java:378)
        at android.net.ConnectivityManager$CallbackHandler.handleMessage(ConnectivityManager.java:2353)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.os.HandlerThread.run(HandlerThread.java:61)


ConnectivityManager.html#getNetworkInfo(android.net.Network)  might return null when Network is invalid. There should be a null check on NetworkInfo before getType().
 
Project Member

Comment 1 by bugdroid1@chromium.org, May 23 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ff2ec75896222f8a2ddc6b9e1551276929a0b671

commit ff2ec75896222f8a2ddc6b9e1551276929a0b671
Author: xunjieli <xunjieli@chromium.org>
Date: Mon May 23 18:50:31 2016

Add a null check in ConnectivityManagerDelegate.getNetworkState

ConnectivityManager.getNetworkInfo can return null if the Network is invalid.
This CL adds a null check so we don't crash with a NullPointerException when
invoking networkInfo.getType()

BUG= 613599 

Review-Url: https://codereview.chromium.org/2003503003
Cr-Commit-Position: refs/heads/master@{#395375}

[modify] https://crrev.com/ff2ec75896222f8a2ddc6b9e1551276929a0b671/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java
[modify] https://crrev.com/ff2ec75896222f8a2ddc6b9e1551276929a0b671/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java

This CL needs to be merged into M52, which was cut last Friday (05/19). I will request a merge once this passed through a Canary release.
Labels: Merge-Request-52
We really need this in the next Android Dev release (which will be cut tomorrow), can we have the merge approval? 

Comment 4 by tin...@google.com, May 23 2016

Labels: -Merge-Request-52 Merge-Approved-52 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M52 (branch: 2743)
Project Member

Comment 5 by bugdroid1@chromium.org, May 23 2016

Labels: -merge-approved-52 merge-merged-2743
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/24e4f8db45cbc45aba6045ab48ccc30234ff2c91

commit 24e4f8db45cbc45aba6045ab48ccc30234ff2c91
Author: xunjieli <xunjieli@chromium.org>
Date: Mon May 23 19:36:59 2016

Add a null check in ConnectivityManagerDelegate.getNetworkState

ConnectivityManager.getNetworkInfo can return null if the Network is invalid.
This CL adds a null check so we don't crash with a NullPointerException when
invoking networkInfo.getType()

BUG= 613599 

TBR=mef@chromium.org,pauljensen@chromium.org
NOTRY=true
NOPRESUBMIT=true

Review-Url: https://codereview.chromium.org/2003503003
Cr-Commit-Position: refs/heads/master@{#395375}
(cherry picked from commit ff2ec75896222f8a2ddc6b9e1551276929a0b671)

Review-Url: https://codereview.chromium.org/2003063003
Cr-Commit-Position: refs/branch-heads/2743@{#13}
Cr-Branched-From: 2b3ae3b8090361f8af5a611712fc1a5ab2de53cb-refs/heads/master@{#394939}

[modify] https://crrev.com/24e4f8db45cbc45aba6045ab48ccc30234ff2c91/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java
[modify] https://crrev.com/24e4f8db45cbc45aba6045ab48ccc30234ff2c91/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java

Status: Fixed (was: Assigned)
Internal bug b/28841033

Comment 8 by mef@chromium.org, May 26 2016

Cc: jouting@google.com judds@google.com kerz@chromium.org
Labels: Merge-Request-52
Per conversation on b/28841033 and chat with jouting@ we need to merge it into 2739 to address crash in the release version.

Please note that this is request to merge into *2739* as it is already merged into 2743.

Comment 9 by tin...@google.com, May 26 2016

Labels: -Merge-Request-52 Merge-Approved-52
Your change meets the bar and is auto-approved for M52 (branch: 2743)
Project Member

Comment 10 by bugdroid1@chromium.org, May 26 2016

Labels: -merge-approved-52 merge-merged-2739
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d95785fc583925674b97a54860e5fa46a168be6b

commit d95785fc583925674b97a54860e5fa46a168be6b
Author: Misha Efimov <mef@google.com>
Date: Thu May 26 18:56:42 2016

Add a null check in ConnectivityManagerDelegate.getNetworkState

ConnectivityManager.getNetworkInfo can return null if the Network is invalid.
This CL adds a null check so we don't crash with a NullPointerException when
invoking networkInfo.getType()

BUG= 613599 

Review-Url: https://codereview.chromium.org/2003503003
Cr-Commit-Position: refs/heads/master@{#395375}
(cherry picked from commit ff2ec75896222f8a2ddc6b9e1551276929a0b671)

R=xunjieli@chromium.org

Review URL: https://codereview.chromium.org/2011123002 .

Cr-Commit-Position: refs/branch-heads/2739@{#7}
Cr-Branched-From: e63177a3d418d078a8777d83f817c11e30831d7b-refs/heads/master@{#393996}

[modify] https://crrev.com/d95785fc583925674b97a54860e5fa46a168be6b/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java
[modify] https://crrev.com/d95785fc583925674b97a54860e5fa46a168be6b/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java

Sign in to add a comment