aboutsummaryrefslogtreecommitdiffstats
path: root/ddms
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2012-06-22 13:42:20 -0700
committerSiva Velusamy <vsiva@google.com>2012-06-22 13:42:20 -0700
commitac7b42776fb6d479ea001b2c1392188c0fa80551 (patch)
tree0176b19d7e33d5304a1fa060c1a723742af68823 /ddms
parent5594fb103d3d232296f17d5cb81e9afaf2cd7beb (diff)
downloadsdk-ac7b42776fb6d479ea001b2c1392188c0fa80551.zip
sdk-ac7b42776fb6d479ea001b2c1392188c0fa80551.tar.gz
sdk-ac7b42776fb6d479ea001b2c1392188c0fa80551.tar.bz2
logcat: fix potential NPE
Fix NPE that could happen if the device goes offline even before logcat command is issued on it, Change-Id: I334caae5e42d25eff396ce0b7b7a5e44c3ed4f61
Diffstat (limited to 'ddms')
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiver.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiver.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiver.java
index 2674e92..da3e86f 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiver.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiver.java
@@ -19,8 +19,8 @@ package com.android.ddmuilib.logcat;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.IShellOutputReceiver;
import com.android.ddmlib.Log;
-import com.android.ddmlib.MultiLineReceiver;
import com.android.ddmlib.Log.LogLevel;
+import com.android.ddmlib.MultiLineReceiver;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -97,7 +97,7 @@ public final class LogCatReceiver {
@Override
public void run() {
/* wait while the device comes online */
- while (!mCurrentDevice.isOnline()) {
+ while (mCurrentDevice != null && !mCurrentDevice.isOnline()) {
try {
Thread.sleep(DEVICE_POLL_INTERVAL_MSEC);
} catch (InterruptedException e) {
@@ -106,8 +106,10 @@ public final class LogCatReceiver {
}
try {
- mCurrentDevice.executeShellCommand(LOGCAT_COMMAND,
+ if (mCurrentDevice != null) {
+ mCurrentDevice.executeShellCommand(LOGCAT_COMMAND,
mCurrentLogCatOutputReceiver, 0);
+ }
} catch (Exception e) {
/* There are 4 possible exceptions: TimeoutException,
* AdbCommandRejectedException, ShellCommandUnresponsiveException and