Skip to content

Commit 90cfe0f

Browse files
Tsu Chiang ChuangAndroid Git Automerger
authored andcommitted
am 2d559b5: Merge "fix NPE in race condition." into ics-mr1
* commit '2d559b5311be1cd909e5a445afe75a840688b822': fix NPE in race condition.
2 parents fef000e + 2d559b5 commit 90cfe0f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
import com.android.bandwidthtest.NetworkState.StateTransitionDirection;
4545
import com.android.internal.util.AsyncChannel;
4646

47+
import junit.framework.Assert;
48+
4749
import java.io.IOException;
4850
import java.net.UnknownHostException;
4951
import java.util.List;
@@ -453,6 +455,11 @@ public boolean waitForNetworkState(int networkType, State expectedState, long ti
453455
} catch (InterruptedException e) {
454456
e.printStackTrace();
455457
}
458+
if (mNetworkInfo == null) {
459+
Log.v(LOG_TAG, "Do not have networkInfo! Force fetch of network info.");
460+
mNetworkInfo = mCM.getActiveNetworkInfo();
461+
Assert.assertNotNull(mNetworkInfo);
462+
}
456463
if ((mNetworkInfo.getType() != networkType) ||
457464
(mNetworkInfo.getState() != expectedState)) {
458465
Log.v(LOG_TAG, "network state for " + mNetworkInfo.getType() +

0 commit comments

Comments
 (0)