bug:3422868 collect additional info to debug this problem
Vasu Nori [Thu, 10 Feb 2011 19:13:09 +0000 (11:13 -0800)]
this bug is not so easy to reproduce.
so, this CL will produce some additional logging info for better insight

Change-Id: I0d53c647f1b98a49eb93b937c8e7203723c33dbe

src/com/android/providers/downloads/DownloadThread.java

index de570ff..100ebca 100644 (file)
@@ -111,6 +111,7 @@ public class DownloadThread extends Thread {
         public String mHeaderContentLocation;
         public int mBytesNotified = 0;
         public long mTimeLastNotification = 0;
+        public long mTotalBytes = -1;
     }
 
     /**
@@ -600,7 +601,8 @@ public class DownloadThread extends Thread {
             header = response.getFirstHeader("Content-Length");
             if (header != null) {
                 innerState.mHeaderContentLength = header.getValue();
-                mInfo.mTotalBytes = Long.parseLong(innerState.mHeaderContentLength);
+                innerState.mTotalBytes = mInfo.mTotalBytes =
+                        Long.parseLong(innerState.mHeaderContentLength);
             }
         } else {
             // Ignore content-length with transfer-encoding - 2616 4.4 3
@@ -656,6 +658,13 @@ public class DownloadThread extends Thread {
      */
     private void handleOtherStatus(State state, InnerState innerState, int statusCode)
             throws StopRequestException {
+        // STOPSHIP remove this. should help in debugging http://b/issue?id=3422868
+        if (statusCode == 416) {
+            // range request failed. it should never fail.
+            throw new IllegalStateException("Http Range request failure: totalBytes = " +
+                    innerState.mTotalBytes + ", bytes recvd so far: " + innerState.mBytesSoFar);
+        }
+        // END STOPSHIP
         int finalStatus;
         if (Downloads.Impl.isStatusError(statusCode)) {
             finalStatus = statusCode;