|
|
Chromium Code Reviews
DescriptionAdd 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
Committed: https://crrev.com/ff2ec75896222f8a2ddc6b9e1551276929a0b671
Cr-Commit-Position: refs/heads/master@{#395375}
Patch Set 1 #
Total comments: 2
Patch Set 2 : Address Misha's comments #Patch Set 3 : Added test #
Total comments: 2
Patch Set 4 : Address Paul's comments #Patch Set 5 : Invoke netIdToNetwork on L+ #
Total comments: 3
Patch Set 6 : Address comments #
Messages
Total messages: 30 (10 generated)
xunjieli@chromium.org changed reviewers: + mef@chromium.org, pauljensen@chromium.org
PTAL. Next dev cut is probably next Tuesday. As long as this gets in before that, I think we will be good.
On 2016/05/20 15:37:47, xunjieli wrote: > PTAL. Next dev cut is probably next Tuesday. As long as this gets in before > that, I think we will be good. Should we enter a crbug for this?
https://codereview.chromium.org/2003503003/diff/1/net/android/java/src/org/ch... File net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java (right): https://codereview.chromium.org/2003503003/diff/1/net/android/java/src/org/ch... net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java:100: if (networkInfo.getType() == TYPE_VPN) { I would probably just add "networkInfo != null &&" condition here instead of duplicating logic from getNetworkState(NetworkInfo networkInfo).
I will create a crbug in a moment. https://codereview.chromium.org/2003503003/diff/1/net/android/java/src/org/ch... File net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java (right): https://codereview.chromium.org/2003503003/diff/1/net/android/java/src/org/ch... net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java:100: if (networkInfo.getType() == TYPE_VPN) { On 2016/05/20 16:37:14, mef wrote: > I would probably just add "networkInfo != null &&" condition here instead of > duplicating logic from getNetworkState(NetworkInfo networkInfo). great idea. Done.
Description was changed from ========== 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() ========== to ========== 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 ==========
On 2016/05/20 16:31:17, mef wrote: > On 2016/05/20 15:37:47, xunjieli wrote: > > PTAL. Next dev cut is probably next Tuesday. As long as this gets in before > > that, I think we will be good. > > Should we enter a crbug for this? Done.
On 2016/05/20 16:55:53, xunjieli wrote: > On 2016/05/20 16:31:17, mef wrote: > > On 2016/05/20 15:37:47, xunjieli wrote: > > > PTAL. Next dev cut is probably next Tuesday. As long as this gets in before > > > that, I think we will be good. > > > > Should we enter a crbug for this? > > Done. Looks good. Can we add a test to NetworkChangeNotifierTest.java? testNetworkCallbacks seems like a good fit.
On 2016/05/20 20:30:18, mef wrote: > On 2016/05/20 16:55:53, xunjieli wrote: > > On 2016/05/20 16:31:17, mef wrote: > > > On 2016/05/20 15:37:47, xunjieli wrote: > > > > PTAL. Next dev cut is probably next Tuesday. As long as this gets in > before > > > > that, I think we will be good. > > > > > > Should we enter a crbug for this? > > > > Done. > > Looks good. Can we add a test to NetworkChangeNotifierTest.java? > testNetworkCallbacks seems like a good fit. Done. Added a test which crashed without the null check. 05-20 17:56:25.011 I/TestRunner(25880): failed: testConnectivityManagerDelegateDoesNotCrash(org.chromium.net.NetworkChangeNotifierTest) 05-20 17:56:25.011 I/TestRunner(25880): ----- begin exception ----- 05-20 17:56:25.011 I/TestRunner(25880): 05-20 17:56:25.011 I/TestRunner(25880): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.net.NetworkInfo.getType()' on a null object reference 05-20 17:56:25.011 I/TestRunner(25880): at org.chromium.net.NetworkChangeNotifierAutoDetect$ConnectivityManagerDelegate.getNetworkState(NetworkChangeNotifierAutoDetect.java:97) 05-20 17:56:25.011 I/TestRunner(25880): at org.chromium.net.NetworkChangeNotifierTest.testConnectivityManagerDelegateDoesNotCrash(NetworkChangeNotifierTest.java:697) 05-20 17:56:25.011 I/TestRunner(25880): at java.lang.reflect.Method.invoke(Native Method) 05-20 17:56:25.011 I/TestRunner(25880): at java.lang.reflect.Method.invoke(Method.java:372) 05-20 17:56:25.011 I/TestRunner(25880): at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214) 05-20 17:56:25.011 I/TestRunner(25880): at android.test.InstrumentationTestCase.access$000(InstrumentationTestCase.java:36) 05-20 17:56:25.011 I/TestRunner(25880): at android.test.InstrumentationTestCase$2.run(InstrumentationTestCase.java:189) 05-20 17:56:25.011 I/TestRunner(25880): at android.app.Instrumentation$SyncRunnable.run(Instrumentation.java:1871) 05-20 17:56:25.011 I/TestRunner(25880): at android.os.Handler.handleCallback(Handler.java:739) 05-20 17:56:25.011 I/TestRunner(25880): at android.os.Handler.dispatchMessage(Handler.java:95) 05-20 17:56:25.011 I/TestRunner(25880): at android.os.Looper.loop(Looper.java:135) 05-20 17:56:25.011 I/TestRunner(25880): at android.app.ActivityThread.main(ActivityThread.java:5254) 05-20 17:56:25.011 I/TestRunner(25880): at java.lang.reflect.Method.invoke(Native Method) 05-20 17:56:25.011 I/TestRunner(25880): at java.lang.reflect.Method.invoke(Method.java:372) 05-20 17:56:25.011 I/TestRunner(25880): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 05-20 17:56:25.011 I/TestRunner(25880): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 05-20 17:56:25.011 I/TestRunner(25880): ----- end exception -----
lgtm https://codereview.chromium.org/2003503003/diff/40001/net/android/javatests/s... File net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java (right): https://codereview.chromium.org/2003503003/diff/40001/net/android/javatests/s... net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java:696: Network invalidNetwork = null; nit: instead of null, maybe you could use netIdToNetwork(NetId.INVALID)
lgtm
https://codereview.chromium.org/2003503003/diff/40001/net/android/javatests/s... File net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java (right): https://codereview.chromium.org/2003503003/diff/40001/net/android/javatests/s... net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java:696: Network invalidNetwork = null; On 2016/05/21 00:33:03, pauljensen wrote: > nit: instead of null, maybe you could use netIdToNetwork(NetId.INVALID) Done.
The CQ bit was checked by xunjieli@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from pauljensen@chromium.org, mef@chromium.org Link to the patchset: https://codereview.chromium.org/2003503003/#ps60001 (title: "Address Paul's comments")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2003503003/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2003503003/60001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_android_rel_ng on tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
https://codereview.chromium.org/2003503003/diff/80001/net/android/javatests/s... File net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java (right): https://codereview.chromium.org/2003503003/diff/80001/net/android/javatests/s... net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java:698: invalidNetwork = netIdToNetwork(NetId.INVALID); Paul, netIdToNetwork uses mNetworkConstructor which is only initialized on L+. Should I surround the call using a conditional? Paul, PTAL.
The CQ bit was checked by xunjieli@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2003503003/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2003503003/80001
https://codereview.chromium.org/2003503003/diff/80001/net/android/javatests/s... File net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java (right): https://codereview.chromium.org/2003503003/diff/80001/net/android/javatests/s... net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java:698: invalidNetwork = netIdToNetwork(NetId.INVALID); On 2016/05/23 16:45:03, xunjieli wrote: > Paul, netIdToNetwork uses mNetworkConstructor which is only initialized on L+. > Should I surround the call using a conditional? Paul, PTAL. is delegate.getNetworkState(Network) callable on pre-Lollipop? The Network class didn't even exist back then I think we should move this whole test into the "if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {" block below
https://codereview.chromium.org/2003503003/diff/80001/net/android/javatests/s... File net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java (right): https://codereview.chromium.org/2003503003/diff/80001/net/android/javatests/s... net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java:698: invalidNetwork = netIdToNetwork(NetId.INVALID); On 2016/05/23 17:19:40, pauljensen wrote: > On 2016/05/23 16:45:03, xunjieli wrote: > > Paul, netIdToNetwork uses mNetworkConstructor which is only initialized on L+. > > Should I surround the call using a conditional? Paul, PTAL. > > is delegate.getNetworkState(Network) callable on pre-Lollipop? > The Network class didn't even exist back then > I think we should move this whole test into the "if (Build.VERSION.SDK_INT >= > Build.VERSION_CODES.LOLLIPOP) {" block below Done.
lgtm
The CQ bit was checked by xunjieli@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from mef@chromium.org Link to the patchset: https://codereview.chromium.org/2003503003/#ps100001 (title: "Address comments")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2003503003/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2003503003/100001
Message was sent while issue was closed.
Description was changed from ========== 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 ========== to ========== 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 ==========
Message was sent while issue was closed.
Committed patchset #6 (id:100001)
Message was sent while issue was closed.
Description was changed from ========== 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 ========== to ========== 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 Committed: https://crrev.com/ff2ec75896222f8a2ddc6b9e1551276929a0b671 Cr-Commit-Position: refs/heads/master@{#395375} ==========
Message was sent while issue was closed.
Patchset 6 (id:??) landed as https://crrev.com/ff2ec75896222f8a2ddc6b9e1551276929a0b671 Cr-Commit-Position: refs/heads/master@{#395375} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
