From 8f93cb71a7cbc023778ffa8c8757abd186a01f41 Mon Sep 17 00:00:00 2001 From: Nishant Chatterjee Date: Tue, 15 Sep 2020 14:09:28 -0700 Subject: [PATCH 1/2] Fixed Typos --- .../util/concurrent/AbstractFutureTest.java | 60 +++++++++---------- .../com/google/common/collect/ArrayTable.java | 2 +- .../com/google/common/io/BaseEncoding.java | 4 +- .../src/com/google/common/io/ByteStreams.java | 2 +- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java index b71e6249563d..da38eac56ae5 100644 --- a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java @@ -87,7 +87,7 @@ public void testException() throws InterruptedException { } public void testCancel_notDoneNoInterrupt() throws Exception { - InterruptibleFuture future = new InterruptibleFuture(); + InterruptableFuture future = new InterruptableFuture(); assertTrue(future.cancel(false)); assertTrue(future.isCancelled()); assertTrue(future.isDone()); @@ -103,7 +103,7 @@ public void testCancel_notDoneNoInterrupt() throws Exception { } public void testCancel_notDoneInterrupt() throws Exception { - InterruptibleFuture future = new InterruptibleFuture(); + InterruptableFuture future = new InterruptableFuture(); assertTrue(future.cancel(true)); assertTrue(future.isCancelled()); assertTrue(future.isDone()); @@ -395,7 +395,7 @@ public void testFutureBash() { final ExecutorService executor = Executors.newFixedThreadPool(barrier.getParties()); final AtomicReference> currentFuture = Atomics.newReference(); final AtomicInteger numSuccessfulSetCalls = new AtomicInteger(); - Callable completeSucessFullyRunnable = + Callable completeSuccessFullyRunnable = new Callable() { @Override public Void call() { @@ -430,7 +430,7 @@ public Void call() { return null; } }; - Callable setFutureCompleteSucessFullyRunnable = + Callable setFutureCompleteSuccessFullyRunnable = new Callable() { ListenableFuture future = Futures.immediateFuture("setFuture"); @@ -511,10 +511,10 @@ public void run() { } }; List> allTasks = new ArrayList<>(); - allTasks.add(completeSucessFullyRunnable); + allTasks.add(completeSuccessFullyRunnable); allTasks.add(completeExceptionallyRunnable); allTasks.add(cancelRunnable); - allTasks.add(setFutureCompleteSucessFullyRunnable); + allTasks.add(setFutureCompleteSuccessFullyRunnable); allTasks.add(setFutureCompleteExceptionallyRunnable); allTasks.add(setFutureCancelRunnable); for (int k = 0; k < 50; k++) { @@ -577,24 +577,24 @@ public void testSetFutureCancelBash() { final ExecutorService executor = Executors.newFixedThreadPool(barrier.getParties()); final AtomicReference> currentFuture = Atomics.newReference(); final AtomicReference> setFutureFuture = Atomics.newReference(); - final AtomicBoolean setFutureSetSucess = new AtomicBoolean(); - final AtomicBoolean setFutureCompletionSucess = new AtomicBoolean(); - final AtomicBoolean cancellationSucess = new AtomicBoolean(); + final AtomicBoolean setFutureSetSuccess = new AtomicBoolean(); + final AtomicBoolean setFutureCompletionSuccess = new AtomicBoolean(); + final AtomicBoolean cancellationSuccess = new AtomicBoolean(); Runnable cancelRunnable = new Runnable() { @Override public void run() { - cancellationSucess.set(currentFuture.get().cancel(true)); + cancellationSuccess.set(currentFuture.get().cancel(true)); awaitUnchecked(barrier); } }; - Runnable setFutureCompleteSucessFullyRunnable = + Runnable setFutureCompleteSuccessFullyRunnable = new Runnable() { @Override public void run() { AbstractFuture future = setFutureFuture.get(); - setFutureSetSucess.set(currentFuture.get().setFuture(future)); - setFutureCompletionSucess.set(future.set("hello-async-world")); + setFutureSetSuccess.set(currentFuture.get().setFuture(future)); + setFutureCompletionSuccess.set(future.set("hello-async-world")); awaitUnchecked(barrier); } }; @@ -640,7 +640,7 @@ public void run() { }; List allTasks = new ArrayList<>(); allTasks.add(cancelRunnable); - allTasks.add(setFutureCompleteSucessFullyRunnable); + allTasks.add(setFutureCompleteSuccessFullyRunnable); for (int k = 0; k < size; k++) { // For each listener we add a task that submits it to the executor directly for the blocking // get usecase and another task that adds it as a listener to the future to exercise both @@ -673,12 +673,12 @@ public void run() { Object result = Iterables.getOnlyElement(finalResults); if (result == CancellationException.class) { assertTrue(future.isCancelled()); - assertTrue(cancellationSucess.get()); + assertTrue(cancellationSuccess.get()); // cancellation can interleave in 3 ways // 1. prior to setFuture // 2. after setFuture before set() on the future assigned // 3. after setFuture and set() are called but before the listener completes. - if (!setFutureSetSucess.get() || !setFutureCompletionSucess.get()) { + if (!setFutureSetSuccess.get() || !setFutureCompletionSuccess.get()) { // If setFuture fails or set on the future fails then it must be because that future was // cancelled assertTrue(setFuture.isCancelled()); @@ -686,14 +686,14 @@ public void run() { } } else { // set on the future completed - assertFalse(cancellationSucess.get()); - assertTrue(setFutureSetSucess.get()); - assertTrue(setFutureCompletionSucess.get()); + assertFalse(cancellationSuccess.get()); + assertTrue(setFutureSetSuccess.get()); + assertTrue(setFutureCompletionSuccess.get()); } // reset for next iteration - setFutureSetSucess.set(false); - setFutureCompletionSucess.set(false); - cancellationSucess.set(false); + setFutureSetSuccess.set(false); + setFutureCompletionSuccess.set(false); + cancellationSuccess.set(false); finalResults.clear(); } executor.shutdown(); @@ -710,17 +710,17 @@ public void testSetFutureCancelBash_withDoneFuture() { final ExecutorService executor = Executors.newFixedThreadPool(barrier.getParties()); final AtomicReference> currentFuture = Atomics.newReference(); final AtomicBoolean setFutureSuccess = new AtomicBoolean(); - final AtomicBoolean cancellationSucess = new AtomicBoolean(); + final AtomicBoolean cancellationSuccess = new AtomicBoolean(); Callable cancelRunnable = new Callable() { @Override public Void call() { - cancellationSucess.set(currentFuture.get().cancel(true)); + cancellationSuccess.set(currentFuture.get().cancel(true)); awaitUnchecked(barrier); return null; } }; - Callable setFutureCompleteSucessFullyRunnable = + Callable setFutureCompleteSuccessFullyRunnable = new Callable() { final ListenableFuture future = Futures.immediateFuture("hello"); @@ -750,7 +750,7 @@ public void run() { }; List> allTasks = new ArrayList<>(); allTasks.add(cancelRunnable); - allTasks.add(setFutureCompleteSucessFullyRunnable); + allTasks.add(setFutureCompleteSuccessFullyRunnable); allTasks.add(Executors.callable(collectResultsRunnable)); assertEquals(allTasks.size() + 1, barrier.getParties()); // sanity check for (int i = 0; i < 1000; i++) { @@ -768,15 +768,15 @@ public void run() { Object result = Iterables.getOnlyElement(finalResults); if (result == CancellationException.class) { assertTrue(future.isCancelled()); - assertTrue(cancellationSucess.get()); + assertTrue(cancellationSuccess.get()); assertFalse(setFutureSuccess.get()); } else { assertTrue(setFutureSuccess.get()); - assertFalse(cancellationSucess.get()); + assertFalse(cancellationSuccess.get()); } // reset for next iteration setFutureSuccess.set(false); - cancellationSucess.set(false); + cancellationSuccess.set(false); finalResults.clear(); } executor.shutdown(); @@ -1269,7 +1269,7 @@ void awaitInLoop() { } } - private static final class InterruptibleFuture extends AbstractFuture { + private static final class InterruptableFuture extends AbstractFuture { boolean interruptTaskWasCalled; @Override diff --git a/guava/src/com/google/common/collect/ArrayTable.java b/guava/src/com/google/common/collect/ArrayTable.java index 3c391447bfc9..f500a892809d 100644 --- a/guava/src/com/google/common/collect/ArrayTable.java +++ b/guava/src/com/google/common/collect/ArrayTable.java @@ -141,7 +141,7 @@ private ArrayTable(Iterable rowKeys, Iterable columnKe * TODO(jlevy): Support only one of rowKey / columnKey being empty? If we * do, when columnKeys is empty but rowKeys isn't, rowKeyList() can contain * elements but rowKeySet() will be empty and containsRow() won't - * acknolwedge them. + * acknowledge them. */ rowKeyToIndex = Maps.indexMap(rowList); columnKeyToIndex = Maps.indexMap(columnList); diff --git a/guava/src/com/google/common/io/BaseEncoding.java b/guava/src/com/google/common/io/BaseEncoding.java index c0874e78407a..e2b7e00429eb 100644 --- a/guava/src/com/google/common/io/BaseEncoding.java +++ b/guava/src/com/google/common/io/BaseEncoding.java @@ -1052,12 +1052,12 @@ public Appendable append(@Nullable CharSequence chars) throws IOException { @GwtIncompatible // Writer static Writer separatingWriter( final Writer delegate, final String separator, final int afterEveryChars) { - final Appendable seperatingAppendable = + final Appendable separatingAppendable = separatingAppendable(delegate, separator, afterEveryChars); return new Writer() { @Override public void write(int c) throws IOException { - seperatingAppendable.append((char) c); + separatingAppendable.append((char) c); } @Override diff --git a/guava/src/com/google/common/io/ByteStreams.java b/guava/src/com/google/common/io/ByteStreams.java index 9becd4223eb9..bdb24dbcc7d3 100644 --- a/guava/src/com/google/common/io/ByteStreams.java +++ b/guava/src/com/google/common/io/ByteStreams.java @@ -167,7 +167,7 @@ public static long copy(ReadableByteChannel from, WritableByteChannel to) throws */ private static byte[] toByteArrayInternal(InputStream in, Queue bufs, int totalLen) throws IOException { - // Starting with an 8k buffer, double the size of each sucessive buffer. Buffers are retained + // Starting with an 8k buffer, double the size of each successive buffer. Buffers are retained // in a deque so that there's no copying between buffers while reading and so all of the bytes // in each new allocated buffer are available for reading from the stream. for (int bufSize = BUFFER_SIZE; From 670365b6459c1e30722301d18bca31f4712addae Mon Sep 17 00:00:00 2001 From: Nishant Chatterjee Date: Tue, 15 Sep 2020 14:19:08 -0700 Subject: [PATCH 2/2] Changed Interruplable To Interruptible --- .../google/common/util/concurrent/AbstractFutureTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java index da38eac56ae5..a86a32ea45f7 100644 --- a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java @@ -87,7 +87,7 @@ public void testException() throws InterruptedException { } public void testCancel_notDoneNoInterrupt() throws Exception { - InterruptableFuture future = new InterruptableFuture(); + InterruptibleFuture future = new InterruptibleFuture(); assertTrue(future.cancel(false)); assertTrue(future.isCancelled()); assertTrue(future.isDone()); @@ -103,7 +103,7 @@ public void testCancel_notDoneNoInterrupt() throws Exception { } public void testCancel_notDoneInterrupt() throws Exception { - InterruptableFuture future = new InterruptableFuture(); + InterruptibleFuture future = new InterruptibleFuture(); assertTrue(future.cancel(true)); assertTrue(future.isCancelled()); assertTrue(future.isDone()); @@ -1269,7 +1269,7 @@ void awaitInLoop() { } } - private static final class InterruptableFuture extends AbstractFuture { + private static final class InterruptibleFuture extends AbstractFuture { boolean interruptTaskWasCalled; @Override