Skip to content

Commit 4bb21de

Browse files
cpovirkJimfs Team
authored andcommitted
Delete assertAsynchronousClose, migrating callers to assertClosed.
The two are equivalent: `assertAsynchronousClose` _looked_ different because it was checking `instanceof AsynchronousCloseException || instanceof ClosedChannelException` instead of just `instanceof ClosedChannelException`. However, [`AsynchronousCloseException`](https://docs.oracle.com/en/java/javase/26/docs/api/java.base/java/nio/channels/AsynchronousCloseException.html) is a subtype of `ClosedChannelException`. RELNOTES=n/a PiperOrigin-RevId: 957265648
1 parent 0dbccb6 commit 4bb21de

1 file changed

Lines changed: 4 additions & 22 deletions

File tree

jimfs/src/test/java/com/google/common/jimfs/JimfsAsynchronousFileChannelTest.java

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@
2828
import static org.junit.Assert.assertNotNull;
2929
import static org.junit.Assert.assertSame;
3030
import static org.junit.Assert.assertThrows;
31-
import static org.junit.Assert.fail;
3231

3332
import com.google.common.collect.ImmutableSet;
3433
import com.google.common.util.concurrent.Runnables;
3534
import com.google.common.util.concurrent.SettableFuture;
3635
import com.google.common.util.concurrent.Uninterruptibles;
3736
import java.io.IOException;
3837
import java.nio.ByteBuffer;
39-
import java.nio.channels.AsynchronousCloseException;
4038
import java.nio.channels.AsynchronousFileChannel;
4139
import java.nio.channels.ClosedChannelException;
4240
import java.nio.channels.CompletionHandler;
@@ -141,8 +139,8 @@ public void testAsyncClose_write() throws Throwable {
141139

142140
channel.close();
143141

144-
assertAsynchronousClose(future);
145-
assertAsynchronousClose(completionHandlerFuture);
142+
assertClosed(future);
143+
assertClosed(completionHandlerFuture);
146144
} finally {
147145
executor.shutdown();
148146
}
@@ -175,8 +173,8 @@ public void testAsyncClose_read() throws Throwable {
175173

176174
channel.close();
177175

178-
assertAsynchronousClose(future);
179-
assertAsynchronousClose(completionHandlerFuture);
176+
assertClosed(future);
177+
assertClosed(completionHandlerFuture);
180178
} finally {
181179
executor.shutdown();
182180
}
@@ -239,20 +237,4 @@ private static void assertClosed(Future<?> future) throws Throwable {
239237
assertThrows(ExecutionException.class, () -> future.get(10, SECONDS));
240238
assertThat(expected).hasCauseThat().isInstanceOf(ClosedChannelException.class);
241239
}
242-
243-
/**
244-
* Assert that the future fails, with the failure caused by either {@code
245-
* AsynchronousCloseException} or (rarely) {@code ClosedChannelException}.
246-
*/
247-
private static void assertAsynchronousClose(Future<?> future) throws Throwable {
248-
ExecutionException expected =
249-
assertThrows(ExecutionException.class, () -> future.get(10, SECONDS));
250-
251-
Throwable t = expected.getCause();
252-
if (!(t instanceof AsynchronousCloseException || t instanceof ClosedChannelException)) {
253-
fail(
254-
"expected AsynchronousCloseException (or in rare cases ClosedChannelException); got "
255-
+ t);
256-
}
257-
}
258240
}

0 commit comments

Comments
 (0)