Skip to content

Commit

Permalink
add logging to CloseHandler tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottmitch committed Jul 16, 2021
1 parent 4800935 commit a3dcaab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.channels.ClosedChannelException;
import java.util.ArrayList;
Expand Down Expand Up @@ -88,6 +90,7 @@
import static org.junit.jupiter.api.Assumptions.assumeTrue;

final class ConnectionCloseHeaderHandlingTest {
private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionCloseHeaderHandlingTest.class);
private static final Collection<Boolean> TRUE_FALSE = asList(true, false);
private static final String SERVER_SHOULD_CLOSE = "serverShouldClose";

Expand Down Expand Up @@ -175,7 +178,10 @@ public Completable accept(final ConnectionContext context) {
assert chunk != null;
requestPayloadSize.addAndGet(chunk.readableBytes());
}
}).beforeOnError(cause -> PayloadWriterUtils.safeClose(writer, cause))
}).beforeOnError(cause -> {
LOGGER.error("failure while writing response", cause);
PayloadWriterUtils.safeClose(writer, cause);
})
.afterFinally(requestPayloadReceived::countDown)
.toFuture();
if (awaitRequestPayload) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.SocketAddress;
Expand Down Expand Up @@ -100,7 +102,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;

class GracefulConnectionClosureHandlingTest {

private static final Logger LOGGER = LoggerFactory.getLogger(GracefulConnectionClosureHandlingTest.class);
private static final Collection<Boolean> TRUE_FALSE = asList(true, false);

@RegisterExtension
Expand Down Expand Up @@ -199,6 +201,7 @@ public Completable accept(final ConnectionContext context) {
}
serverReceivedRequestPayload.add(receivedSize);
}).beforeOnError(cause -> {
LOGGER.error("failure while writing response", cause);
serverReceivedRequestPayload.add(-1);
PayloadWriterUtils.safeClose(writer, cause);
}).toFuture();
Expand Down

0 comments on commit a3dcaab

Please sign in to comment.