Skip to content

Instantly share code, notes, and snippets.

@cenodis
Last active April 21, 2024 23:13
Show Gist options
  • Save cenodis/f1ac900dfe0ddc9b8a7441d636810f32 to your computer and use it in GitHub Desktop.
Save cenodis/f1ac900dfe0ddc9b8a7441d636810f32 to your computer and use it in GitHub Desktop.
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.newsclub.net.unix.AFUNIXServerSocketChannel;
import org.newsclub.net.unix.AFUNIXSocket;
import org.newsclub.net.unix.AFUNIXSocketAddress;
import org.newsclub.net.unix.AFUNIXSocketChannel;
import org.newsclub.net.unix.AFUNIXServerSocket;
import java.io.IOException;
import java.net.SocketException;
import java.net.StandardProtocolFamily;
import java.net.UnixDomainSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import static org.junit.jupiter.api.Assertions.*;
public class InterruptTest {
private static final Path SOCKET_PATH = Path.of("/", "tmp", "test_socket");
private static final AFUNIXSocketAddress SOCKET_ADDR;
static {
try {
SOCKET_ADDR = AFUNIXSocketAddress.of(SOCKET_PATH);
} catch (SocketException e) {
throw new RuntimeException(e);
}
}
private static List<Arguments> clientProvider() {
return List.of(
socket(false, AFUNIXSocket::newInstance, s -> s.connect(SOCKET_ADDR), SocketException.class, AFUNIXSocket::isClosed),
socket(true, () -> AFUNIXSocket.connectTo(SOCKET_ADDR), s -> s.getInputStream().read(), SocketException.class, AFUNIXSocket::isClosed),
socket(true, () -> AFUNIXSocket.connectTo(SOCKET_ADDR), s -> s.getOutputStream().write(10), SocketException.class, AFUNIXSocket::isClosed),
socket(false, AFUNIXSocketChannel::open, s -> s.connect(SOCKET_ADDR), ClosedByInterruptException.class, s -> !s.isOpen()),
socket(
true,
InterruptTest::connectSocketChannel,
s -> s.read(ByteBuffer.allocate(1)),
ClosedByInterruptException.class,
s -> !s.isOpen()
),
socket(
true,
InterruptTest::connectSocketChannel,
s -> s.write(ByteBuffer.allocate(1)),
ClosedByInterruptException.class,
s -> !s.isOpen()
)
);
}
private static List<Arguments> serverProvider() {
return List.of(
serverSocket(() -> AFUNIXServerSocket.bindOn(SOCKET_ADDR), AFUNIXServerSocket::accept, SocketException.class, AFUNIXServerSocket::isClosed),
serverSocket(InterruptTest::bindServerSocketChannel, AFUNIXServerSocketChannel::accept, ClosedByInterruptException.class, s -> !s.isOpen())
);
}
@ParameterizedTest
@MethodSource("clientProvider")
<T extends AutoCloseable> void testClientInterruption(
boolean acceptConnections,
IOSupplier<T> socket,
IOConsumer<T> blockingOp,
Class<?> expectedException,
Predicate<T> closeCheck
) throws Throwable {
withServer(
acceptConnections,
() -> testSocketInterruption(false, socket, blockingOp, expectedException, closeCheck)
);
}
@ParameterizedTest
@MethodSource("clientProvider")
<T extends AutoCloseable> void testClientInterruptionWithDelay(
boolean acceptConnections,
IOSupplier<T> socket,
IOConsumer<T> blockingOp,
Class<?> expectedException,
Predicate<T> closeCheck
) throws Throwable {
withServer(
acceptConnections,
() -> testSocketInterruption(true, socket, blockingOp, expectedException, closeCheck)
);
}
@ParameterizedTest
@MethodSource("serverProvider")
<T extends AutoCloseable> void testServerInterruption(
IOSupplier<T> socket,
IOConsumer<T> blockingOp,
Class<?> expectedException,
Predicate<T> closeCheck
) throws Throwable {
try {
testSocketInterruption(
false,
socket,
blockingOp,
expectedException,
closeCheck
);
} finally {
Files.deleteIfExists(SOCKET_PATH);
}
}
@ParameterizedTest
@MethodSource("serverProvider")
<T extends AutoCloseable> void testServerInterruptionWithDelay(
IOSupplier<T> socket,
IOConsumer<T> blockingOp,
Class<?> expectedException,
Predicate<T> closeCheck
) throws Throwable {
try {
testSocketInterruption(
true,
socket,
blockingOp,
expectedException,
closeCheck
);
} finally {
Files.deleteIfExists(SOCKET_PATH);
}
}
<T extends AutoCloseable> void testSocketInterruption(
boolean delay,
IOSupplier<T> socket,
IOConsumer<T> blockingOp,
Class<?> expectedException,
Predicate<T> closeCheck
) throws Throwable {
var exceptionHolder = new AtomicReference<Throwable>();
var ready = new CountDownLatch(1);
var t = Thread.ofVirtual()
.start(() -> exceptionHolder.set(runOperation(
ready,
socket,
blockingOp,
expectedException,
closeCheck
)));
ready.await();
if (delay) {
Thread.sleep(500);
}
t.interrupt();
if (!t.join(Duration.of(1, ChronoUnit.SECONDS))) {
throw new RuntimeException("Thread failed to terminate after interrupt");
}
var thrownException = exceptionHolder.get();
if (thrownException != null) {
throw thrownException;
}
}
private static void withServer(boolean acceptConnections, ThrowingRunnable func) throws Throwable {
try(var serverSocket = ServerSocketChannel.open(StandardProtocolFamily.UNIX)) {
serverSocket.bind(UnixDomainSocketAddress.of(SOCKET_PATH));
Thread serverThread = null;
if (acceptConnections) {
serverThread = Thread.ofPlatform()
.daemon(true)
.start(() -> {
var clients = new ArrayList<SocketChannel>();
while (serverSocket.isOpen()) {
try {
var socket = serverSocket.accept();
clients.add(socket);
} catch (ClosedChannelException e) {
return;
} catch (IOException e) {
throw new RuntimeException("Unable to accept socket ", e);
} finally {
for (var client : clients) {
try {
client.close();
} catch (IOException ignored) {
}
}
}
}
});
}
try {
func.run();
} finally {
serverSocket.close();
if (serverThread != null) {
serverThread.join();
}
}
} finally {
Files.deleteIfExists(SOCKET_PATH);
}
}
<T extends AutoCloseable> Throwable runOperation(
CountDownLatch ready,
IOSupplier<T> socket,
IOConsumer<T> blockingOp,
Class<?> expectedException,
Predicate<T> closeCheck
) {
try {
var sock = socket.get();
ready.countDown();
try {
blockingOp.accept(sock);
} catch (Exception e) {
assertAll(
() -> assertInstanceOf(expectedException, e, "Socket exception"),
() -> assertTrue(Thread.interrupted(), "Thread interrupted"),
() -> assertTrue(closeCheck.test(sock), "Socket closed")
);
} finally {
ready.countDown();
if (sock != null) {
try {
sock.close();
} catch (Exception e) {
throw new RuntimeException("Unable to clean up socket", e);
}
}
}
} catch (Throwable e) {
return e;
}
return null;
}
private static <T> Arguments socket(
boolean acceptConnections,
IOSupplier<T> socket,
IOConsumer<T> blockingOp,
Class<?> expectedException,
Predicate<T> closeCheck
) {
return Arguments.of(acceptConnections, socket, blockingOp, expectedException, closeCheck);
}
private static <T> Arguments serverSocket(
IOSupplier<T> socket,
IOConsumer<T> blockingOp,
Class<?> expectedException,
Predicate<T> closeCheck
) {
return Arguments.of(socket, blockingOp, expectedException, closeCheck);
}
private static AFUNIXSocketChannel connectSocketChannel() throws IOException {
var socket = AFUNIXSocketChannel.open();
socket.connect(SOCKET_ADDR);
return socket;
}
private static AFUNIXServerSocketChannel bindServerSocketChannel() throws IOException {
var socket = AFUNIXServerSocketChannel.open();
socket.bind(SOCKET_ADDR);
return socket;
}
private interface IOSupplier<T> {
T get() throws IOException;
}
private interface IOConsumer<T> {
void accept(T t) throws IOException;
}
private interface ThrowingRunnable {
void run() throws Throwable;
}
}
-------------------------------------------------------------------------------
Test set: InterruptTest
-------------------------------------------------------------------------------
Tests run: 16, Failures: 8, Errors: 0, Skipped: 0, Time elapsed: 4.298 s <<< FAILURE! -- in InterruptTest
InterruptTest.testClientInterruption(boolean, IOSupplier, IOConsumer, Class, Predicate)[2] -- Time elapsed: 0.012 s <<< FAILURE!
org.opentest4j.MultipleFailuresError:
Multiple Failures (1 failure)
org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:80)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:44)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:38)
at org.junit.jupiter.api.Assertions.assertAll(Assertions.java:2944)
at InterruptTest.runOperation(InterruptTest.java:236)
at InterruptTest.lambda$testSocketInterruption$15(InterruptTest.java:160)
at java.base/java.lang.VirtualThread.run(VirtualThread.java:309)
Suppressed: org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
at InterruptTest.lambda$runOperation$19(InterruptTest.java:239)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
InterruptTest.testClientInterruption(boolean, IOSupplier, IOConsumer, Class, Predicate)[3] -- Time elapsed: 0.003 s <<< FAILURE!
org.opentest4j.MultipleFailuresError:
Multiple Failures (1 failure)
org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:80)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:44)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:38)
at org.junit.jupiter.api.Assertions.assertAll(Assertions.java:2944)
at InterruptTest.runOperation(InterruptTest.java:236)
at InterruptTest.lambda$testSocketInterruption$15(InterruptTest.java:160)
at java.base/java.lang.VirtualThread.run(VirtualThread.java:309)
Suppressed: org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
at InterruptTest.lambda$runOperation$19(InterruptTest.java:239)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
InterruptTest.testClientInterruption(boolean, IOSupplier, IOConsumer, Class, Predicate)[5] -- Time elapsed: 0.003 s <<< FAILURE!
org.opentest4j.MultipleFailuresError:
Multiple Failures (2 failures)
org.opentest4j.AssertionFailedError: Socket exception ==> Unexpected type, expected: <java.nio.channels.ClosedByInterruptException> but was: <java.nio.channels.ClosedChannelException>
org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:80)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:44)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:38)
at org.junit.jupiter.api.Assertions.assertAll(Assertions.java:2944)
at InterruptTest.runOperation(InterruptTest.java:236)
at InterruptTest.lambda$testSocketInterruption$15(InterruptTest.java:160)
at java.base/java.lang.VirtualThread.run(VirtualThread.java:309)
Suppressed: org.opentest4j.AssertionFailedError: Socket exception ==> Unexpected type, expected: <java.nio.channels.ClosedByInterruptException> but was: <java.nio.channels.ClosedChannelException>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertInstanceOf.assertInstanceOf(AssertInstanceOf.java:49)
at org.junit.jupiter.api.AssertInstanceOf.assertInstanceOf(AssertInstanceOf.java:35)
at org.junit.jupiter.api.Assertions.assertInstanceOf(Assertions.java:3599)
at InterruptTest.lambda$runOperation$17(InterruptTest.java:237)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
Suppressed: org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
at InterruptTest.lambda$runOperation$19(InterruptTest.java:239)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
InterruptTest.testClientInterruption(boolean, IOSupplier, IOConsumer, Class, Predicate)[6] -- Time elapsed: 0.003 s <<< FAILURE!
org.opentest4j.MultipleFailuresError:
Multiple Failures (2 failures)
org.opentest4j.AssertionFailedError: Socket exception ==> Unexpected type, expected: <java.nio.channels.ClosedByInterruptException> but was: <org.newsclub.net.unix.BrokenPipeSocketException>
org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:80)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:44)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:38)
at org.junit.jupiter.api.Assertions.assertAll(Assertions.java:2944)
at InterruptTest.runOperation(InterruptTest.java:236)
at InterruptTest.lambda$testSocketInterruption$15(InterruptTest.java:160)
at java.base/java.lang.VirtualThread.run(VirtualThread.java:309)
Suppressed: org.opentest4j.AssertionFailedError: Socket exception ==> Unexpected type, expected: <java.nio.channels.ClosedByInterruptException> but was: <org.newsclub.net.unix.BrokenPipeSocketException>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertInstanceOf.assertInstanceOf(AssertInstanceOf.java:49)
at org.junit.jupiter.api.AssertInstanceOf.assertInstanceOf(AssertInstanceOf.java:35)
at org.junit.jupiter.api.Assertions.assertInstanceOf(Assertions.java:3599)
at InterruptTest.lambda$runOperation$17(InterruptTest.java:237)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
Suppressed: org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
at InterruptTest.lambda$runOperation$19(InterruptTest.java:239)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
InterruptTest.testServerInterruption(IOSupplier, IOConsumer, Class, Predicate)[2] -- Time elapsed: 0.003 s <<< FAILURE!
org.opentest4j.MultipleFailuresError:
Multiple Failures (1 failure)
org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:80)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:44)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:38)
at org.junit.jupiter.api.Assertions.assertAll(Assertions.java:2944)
at InterruptTest.runOperation(InterruptTest.java:236)
at InterruptTest.lambda$testSocketInterruption$15(InterruptTest.java:160)
at java.base/java.lang.VirtualThread.run(VirtualThread.java:309)
Suppressed: org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
at InterruptTest.lambda$runOperation$19(InterruptTest.java:239)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
InterruptTest.testClientInterruptionWithDelay(boolean, IOSupplier, IOConsumer, Class, Predicate)[5] -- Time elapsed: 0.503 s <<< FAILURE!
org.opentest4j.MultipleFailuresError:
Multiple Failures (3 failures)
org.opentest4j.AssertionFailedError: Socket exception ==> Unexpected type, expected: <java.nio.channels.ClosedByInterruptException> but was: <java.nio.channels.ClosedChannelException>
org.opentest4j.AssertionFailedError: Thread interrupted ==> expected: <true> but was: <false>
org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:80)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:44)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:38)
at org.junit.jupiter.api.Assertions.assertAll(Assertions.java:2944)
at InterruptTest.runOperation(InterruptTest.java:236)
at InterruptTest.lambda$testSocketInterruption$15(InterruptTest.java:160)
at java.base/java.lang.VirtualThread.run(VirtualThread.java:309)
Suppressed: org.opentest4j.AssertionFailedError: Socket exception ==> Unexpected type, expected: <java.nio.channels.ClosedByInterruptException> but was: <java.nio.channels.ClosedChannelException>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertInstanceOf.assertInstanceOf(AssertInstanceOf.java:49)
at org.junit.jupiter.api.AssertInstanceOf.assertInstanceOf(AssertInstanceOf.java:35)
at org.junit.jupiter.api.Assertions.assertInstanceOf(Assertions.java:3599)
at InterruptTest.lambda$runOperation$17(InterruptTest.java:237)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
Suppressed: org.opentest4j.AssertionFailedError: Thread interrupted ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
at InterruptTest.lambda$runOperation$18(InterruptTest.java:238)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
Suppressed: org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
at InterruptTest.lambda$runOperation$19(InterruptTest.java:239)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
InterruptTest.testClientInterruptionWithDelay(boolean, IOSupplier, IOConsumer, Class, Predicate)[6] -- Time elapsed: 0.503 s <<< FAILURE!
org.opentest4j.MultipleFailuresError:
Multiple Failures (3 failures)
org.opentest4j.AssertionFailedError: Socket exception ==> Unexpected type, expected: <java.nio.channels.ClosedByInterruptException> but was: <org.newsclub.net.unix.BrokenPipeSocketException>
org.opentest4j.AssertionFailedError: Thread interrupted ==> expected: <true> but was: <false>
org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:80)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:44)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:38)
at org.junit.jupiter.api.Assertions.assertAll(Assertions.java:2944)
at InterruptTest.runOperation(InterruptTest.java:236)
at InterruptTest.lambda$testSocketInterruption$15(InterruptTest.java:160)
at java.base/java.lang.VirtualThread.run(VirtualThread.java:309)
Suppressed: org.opentest4j.AssertionFailedError: Socket exception ==> Unexpected type, expected: <java.nio.channels.ClosedByInterruptException> but was: <org.newsclub.net.unix.BrokenPipeSocketException>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertInstanceOf.assertInstanceOf(AssertInstanceOf.java:49)
at org.junit.jupiter.api.AssertInstanceOf.assertInstanceOf(AssertInstanceOf.java:35)
at org.junit.jupiter.api.Assertions.assertInstanceOf(Assertions.java:3599)
at InterruptTest.lambda$runOperation$17(InterruptTest.java:237)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
Suppressed: org.opentest4j.AssertionFailedError: Thread interrupted ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
at InterruptTest.lambda$runOperation$18(InterruptTest.java:238)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
Suppressed: org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
at InterruptTest.lambda$runOperation$19(InterruptTest.java:239)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
InterruptTest.testServerInterruptionWithDelay(IOSupplier, IOConsumer, Class, Predicate)[2] -- Time elapsed: 0.503 s <<< FAILURE!
org.opentest4j.MultipleFailuresError:
Multiple Failures (1 failure)
org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:80)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:44)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:38)
at org.junit.jupiter.api.Assertions.assertAll(Assertions.java:2944)
at InterruptTest.runOperation(InterruptTest.java:236)
at InterruptTest.lambda$testSocketInterruption$15(InterruptTest.java:160)
at java.base/java.lang.VirtualThread.run(VirtualThread.java:309)
Suppressed: org.opentest4j.AssertionFailedError: Socket closed ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
at InterruptTest.lambda$runOperation$19(InterruptTest.java:239)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$0(AssertAll.java:68)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:77)
... 6 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment