From 28310268d9051b1354eb33035818e2b1651efa4b Mon Sep 17 00:00:00 2001 From: JW Wang Date: Mon, 30 Mar 2020 10:19:36 +0800 Subject: [PATCH] Fix an NPE in WatchdogEventLogger#stop See b/152550404#comment15. https://cs.corp.google.com/android/frameworks/base/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java?rcl=0b9230489ead3a2ad328d46a47194cfa9dffd25c&l=86 My theory is that somehow #setUp throws before calling mLogger.start() and then mLogger.stop() runs into an NPE. Let's add a null-check in the hope that the actual root cause will stand out. Bug: 152550404 Test: atest StagedRollbackTest Change-Id: Ifd323e6a8707a2de19d03ecbe536feacdbb4e9c6 --- .../android/tests/rollback/host/WatchdogEventLogger.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/RollbackTest/lib/src/com/android/tests/rollback/host/WatchdogEventLogger.java b/tests/RollbackTest/lib/src/com/android/tests/rollback/host/WatchdogEventLogger.java index 317d67e3791e2..88731504eafe4 100644 --- a/tests/RollbackTest/lib/src/com/android/tests/rollback/host/WatchdogEventLogger.java +++ b/tests/RollbackTest/lib/src/com/android/tests/rollback/host/WatchdogEventLogger.java @@ -36,8 +36,10 @@ public class WatchdogEventLogger { } public void stop() { - mReceiver.stop(); - mReceiver.clear(); + if (mReceiver != null) { + mReceiver.stop(); + mReceiver.clear(); + } } /**