Skip to content

Commit

Permalink
lint: apply code style
Browse files Browse the repository at this point in the history
  • Loading branch information
dachshu committed May 3, 2024
1 parent 5e25804 commit 151ff7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -796,10 +796,10 @@ private void handleRequestOrResponseComplete() {
handledLastRequest = true;
if (unfinishedRequests.isEmpty()) {
ctx.channel().eventLoop().schedule(() -> {
if (ctx.channel().isActive()) {
ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(CLOSE);
}
}, Flags.defaultHttp1ConnectionCloseDelayMillis(), TimeUnit.MILLISECONDS);
if (ctx.channel().isActive()) {
ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(CLOSE);
}
}, Flags.defaultHttp1ConnectionCloseDelayMillis(), TimeUnit.MILLISECONDS);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ protected void configure(ServerBuilder sb) {
sb.tlsSelfSigned();
sb.service("/close", (ctx, req) -> {
return HttpResponse.builder()
.ok()
.content("OK\n")
.header(HttpHeaderNames.CONNECTION, "close")
.build();
.ok()
.content("OK\n")
.header(HttpHeaderNames.CONNECTION, "close")
.build();
});
}
};
Expand All @@ -66,7 +66,7 @@ protected void configure(ServerBuilder sb) {
void shouldDelayDisconnectByServerSideIfClientDoesNotHandleConnectionClose() throws IOException {
final Random random = new Random();
final short localPort = (short) random.nextInt(Short.MAX_VALUE + 1);
try (Socket socket = new Socket("127.0.0.1", server.httpPort(), null, localPort)) {
try (Socket socket = new Socket("127.0.0.1", server.httpPort(), null, localPort)) {
socket.setSoTimeout(100000);
final PrintWriter writer = new PrintWriter(socket.getOutputStream());
writer.print("GET /close" + " HTTP/1.1\r\n");
Expand Down Expand Up @@ -105,7 +105,7 @@ void shouldDelayDisconnectByServerSideIfClientDoesNotHandleConnectionClose() thr
// Additional test to check that the socket is in the CLOSED state
if (SystemInfo.osType() == OsType.LINUX || SystemInfo.osType() == OsType.MAC) {
socket.close();
try(Socket reuseSock = new Socket()) {
try (Socket reuseSock = new Socket()) {
assertThatCode(() -> reuseSock.bind(new InetSocketAddress((InetAddress) null, localPort)))
.doesNotThrowAnyException();
}
Expand All @@ -117,7 +117,7 @@ void shouldDelayDisconnectByServerSideIfClientDoesNotHandleConnectionClose() thr
void shouldWaitForDisconnectByClientSideFirst() throws IOException {
final Random random = new Random();
final short localPort = (short) random.nextInt(Short.MAX_VALUE + 1);
try (Socket socket = new Socket("127.0.0.1", server.httpPort(), null, localPort)) {
try (Socket socket = new Socket("127.0.0.1", server.httpPort(), null, localPort)) {
socket.setSoTimeout(100000);
final PrintWriter writer = new PrintWriter(socket.getOutputStream());
writer.print("GET /close" + " HTTP/1.1\r\n");
Expand Down Expand Up @@ -146,8 +146,9 @@ void shouldWaitForDisconnectByClientSideFirst() throws IOException {
// Additional test to check that the socket is in the TIMED_WAIT state
if (SystemInfo.osType() == OsType.LINUX || SystemInfo.osType() == OsType.MAC) {
socket.close();
try(Socket reuseSock = new Socket()) {
assertThatThrownBy(() -> reuseSock.bind(new InetSocketAddress((InetAddress) null, localPort)))
try (Socket reuseSock = new Socket()) {
assertThatThrownBy(
() -> reuseSock.bind(new InetSocketAddress((InetAddress) null, localPort)))
.isInstanceOf(BindException.class)
.hasMessageContaining("Address already in use");
}
Expand Down

0 comments on commit 151ff7a

Please sign in to comment.