From 8374b3dd67ecdb62423ff55ccb9d0a4454cfe4a4 Mon Sep 17 00:00:00 2001 From: Colin Mahoney Date: Thu, 9 Jan 2014 17:20:43 +0100 Subject: [PATCH] CB-5631 Removed SimpleTrackingInputStream.read(byte[] buffer) InputStream.read(byte[] buffer) calls InputStream.read(byte[] bytes, int offset, int count). As SimpleTrackingInputStream overrides both these methods a call to SimpleTrackingInputStream.read(byte[] buffer) results in a call to SimpleTrackingInputStream.read(byte[] bytes, int offset, int count) - and two calls to SimpleTrackingInputStream.updateBytesRead, so the counter bytesRead gets incremented twice for each read. --- src/android/FileTransfer.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/android/FileTransfer.java b/src/android/FileTransfer.java index 5d7cbc0..079cd91 100644 --- a/src/android/FileTransfer.java +++ b/src/android/FileTransfer.java @@ -158,11 +158,8 @@ public class FileTransfer extends CordovaPlugin { return updateBytesRead(super.read()); } - @Override - public int read(byte[] buffer) throws IOException { - return updateBytesRead(super.read(buffer)); - } - + // Note: FilterInputStream delegates read(byte[] bytes) to the below method, + // so we don't override it or else double count (CB-5631). @Override public int read(byte[] bytes, int offset, int count) throws IOException { return updateBytesRead(super.read(bytes, offset, count));