Merge "fix a bug in crash handling"
diff --git a/tests/src/com/android/browser/PopularUrlsTest.java b/tests/src/com/android/browser/PopularUrlsTest.java
index 5e367be..3e7515f 100644
--- a/tests/src/com/android/browser/PopularUrlsTest.java
+++ b/tests/src/com/android/browser/PopularUrlsTest.java
@@ -305,12 +305,14 @@
         private int page;
         private String url;
         private boolean isRecovery;
+        private boolean allClear;
 
         private RunStatus(File file) throws IOException {
             mFile = file;
             FileReader input = null;
             BufferedReader reader = null;
             isRecovery = false;
+            allClear = false;
             iteration = 0;
             page = 0;
             try {
@@ -369,7 +371,9 @@
         }
 
         public void cleanUp() {
-            if (mFile.exists()) {
+            // only perform cleanup when allClear flag is set
+            // i.e. when the test was not interrupted by a Java crash
+            if (mFile.exists() && allClear) {
                 mFile.delete();
             }
         }
@@ -380,6 +384,7 @@
 
         public void incrementPage() {
             ++page;
+            allClear = true;
         }
 
         public void incrementIteration() {
@@ -400,6 +405,7 @@
 
         public void setUrl(String url) {
             this.url = url;
+            allClear = false;
         }
     }