From 7ac7ede663e3199e8fc8881bacb8a59a146be5d6 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 10 Jul 2019 08:47:09 -0700 Subject: [PATCH] Fixing more Storage code style issues --- .../firebase/firestore/FirebaseFirestore.java | 6 +- .../firebase/storage/StreamDownloadTask.java | 117 +++++++++--------- .../storage/network/NetworkRequest.java | 52 ++++---- .../firebase/storage/DependencyTest.java | 4 +- .../google/firebase/storage/RetryRule.java | 3 +- .../com/google/firebase/storage/TestUtil.java | 2 +- .../network/MockConnectionFactory.java | 20 +-- 7 files changed, 101 insertions(+), 103 deletions(-) diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java index 1d8fb8c625c..d6348336a6e 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java @@ -261,15 +261,15 @@ public Query collectionGroup(@NonNull String collectionId) { * @param executor The executor to run the transaction callback on. * @return The task returned from the updateFunction. */ - private Task runTransaction( - Transaction.Function updateFunction, Executor executor) { + private Task runTransaction( + Transaction.Function updateFunction, Executor executor) { ensureClientConfigured(); // We wrap the function they provide in order to // 1. Use internal implementation classes for Transaction, // 2. Convert exceptions they throw into Tasks, and // 3. Run the user callback on the user queue. - Function> wrappedUpdateFunction = + Function> wrappedUpdateFunction = internalTransaction -> Tasks.call( executor, diff --git a/firebase-storage/src/main/java/com/google/firebase/storage/StreamDownloadTask.java b/firebase-storage/src/main/java/com/google/firebase/storage/StreamDownloadTask.java index 4eb7fc18ee6..a617a9b7315 100644 --- a/firebase-storage/src/main/java/com/google/firebase/storage/StreamDownloadTask.java +++ b/firebase-storage/src/main/java/com/google/firebase/storage/StreamDownloadTask.java @@ -38,24 +38,24 @@ public class StreamDownloadTask extends StorageTask { static final long PREFERRED_CHUNK_SIZE = 256 * 1024; private static final String TAG = "StreamDownloadTask"; - private StorageReference mStorageRef; - private ExponentialBackoffSender mSender; - private volatile Exception mException = null; - private volatile int mResultCode = 0; - private StreamProcessor mProcessor; - - private long mTotalBytes = -1; - private long mBytesDownloaded; - private long mBytesDownloadedSnapped; - private InputStream mInputStream; - private NetworkRequest mRequest; - private String mETagVerification; + private StorageReference storageRef; + private ExponentialBackoffSender sender; + private volatile Exception exception = null; + private volatile int resultCode = 0; + private StreamProcessor processor; + + private long totalBytes = -1; + private long bytesDownloaded; + private long bytesDownloadedSnapped; + private InputStream inputStream; + private NetworkRequest request; + private String eTagVerification; /*package*/ StreamDownloadTask(@NonNull StorageReference storageRef) { - mStorageRef = storageRef; + this.storageRef = storageRef; - FirebaseStorage storage = mStorageRef.getStorage(); - mSender = + FirebaseStorage storage = this.storageRef.getStorage(); + sender = new ExponentialBackoffSender( storage.getApp().getApplicationContext(), storage.getAuthProvider(), @@ -71,8 +71,8 @@ public class StreamDownloadTask extends StorageTask verifications = new ArrayList<>(); - int count = 0; - private BufferedReader br; + private HttpURLConnection oldMock; + private List verifications = new ArrayList<>(); + private final BufferedReader br; + private final Semaphore pauseSemaphore = new Semaphore(0); + private int lineCount = 0; private int pauseRecord = Integer.MAX_VALUE; - private int currentRecord = 0; - private Semaphore pauseSemaphore = new Semaphore(0); + private int currentRecord = 0;; public MockConnectionFactory(String testName, boolean binaryBody) { this.binaryBody = binaryBody; @@ -91,7 +91,7 @@ public synchronized HttpURLConnection createInstance(@NonNull URL url) throws IO String line; try { while ((line = br.readLine()) != null) { - count++; + lineCount++; if ("".equalsIgnoreCase(line)) { break; @@ -156,7 +156,7 @@ public synchronized HttpURLConnection createInstance(@NonNull URL url) throws IO } } } catch (ComparisonFailure | IllegalArgumentException e) { - System.out.println("**** Error at line:" + count); + System.out.println("**** Error at line:" + lineCount); throw e; } currentRecord++; @@ -179,7 +179,7 @@ public synchronized HttpURLConnection createInstance(@NonNull URL url) throws IO } public synchronized void verifyOldMock() { - if (oldMock == null || verifications.size() == 0) { + if (oldMock == null || verifications.isEmpty()) { return; } List requestPropertyKeys = new ArrayList<>(); @@ -233,7 +233,7 @@ public synchronized void verifyOldMock() { valueCapture.getAllValues().get(keyIndex)); } } catch (MockitoAssertionError | ComparisonFailure e) { - System.out.println("**********Error in network Line: " + count); + System.out.println("**********Error in network Line: " + lineCount); throw e; }