Skip to content

Commit 3e21ec5

Browse files
committed
Added CLOSED_CHANNEL_ERROR_MESSAGE to fix compilation issues
1 parent beff89c commit 3e21ec5

File tree

2 files changed

+23
-14
lines changed
  • http-clients/netty-nio-client/src

2 files changed

+23
-14
lines changed

http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/utils/NettyUtils.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ public final class NettyUtils {
5353
*/
5454
public static final SucceededFuture<?> SUCCEEDED_FUTURE = new SucceededFuture<>(null, null);
5555

56+
public static final String CLOSED_CHANNEL_ERROR_MESSAGE = "The connection was closed during the request. The request will "
57+
+ "usually succeed on a "
58+
+ "retry, but if it does"
59+
+ " not: consider disabling any proxies you have configured, "
60+
+ "enabling debug logging, or "
61+
+ "performing a TCP"
62+
+ " dump to identify the root cause. If this is a streaming "
63+
+ "operation, validate that data"
64+
+ " is being read or"
65+
+ " written in a timely manner.";
5666
private static final Logger log = Logger.loggerFor(NettyUtils.class);
5767

5868
private NettyUtils() {
@@ -140,10 +150,7 @@ public static String closedChannelMessage(Channel channel) {
140150
channel.parent().attr(CHANNEL_DIAGNOSTICS).get() : null;
141151

142152
StringBuilder error = new StringBuilder();
143-
error.append("The connection was closed during the request. The request will usually succeed on a retry, but if it does"
144-
+ " not: consider disabling any proxies you have configured, enabling debug logging, or performing a TCP"
145-
+ " dump to identify the root cause. If this is a streaming operation, validate that data is being read or"
146-
+ " written in a timely manner.");
153+
error.append(CLOSED_CHANNEL_ERROR_MESSAGE);
147154

148155
if (channelDiagnostics != null) {
149156
error.append(" Channel Information: ").append(channelDiagnostics);

http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/utils/NettyUtilsTest.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import io.netty.handler.ssl.SslContext;
3030
import io.netty.handler.ssl.SslContextBuilder;
3131
import io.netty.handler.ssl.SslHandler;
32+
import io.netty.util.Attribute;
3233
import io.netty.util.AttributeKey;
3334
import io.netty.util.concurrent.EventExecutor;
3435
import io.netty.util.concurrent.Future;
@@ -41,6 +42,7 @@
4142
import org.junit.jupiter.api.AfterAll;
4243
import org.junit.jupiter.api.BeforeAll;
4344
import org.junit.jupiter.api.Test;
45+
import org.mockito.Mockito;
4446
import org.slf4j.Logger;
4547
import software.amazon.awssdk.http.nio.netty.internal.MockChannel;
4648

@@ -222,7 +224,7 @@ public void runAndLogError_runnableThrows_loggerInvoked() {
222224

223225
verify(delegateLogger).error(msg, error);
224226
}
225-
227+
226228
@Test
227229
public void closedChannelMessage_with_nullChannelAttribute() throws Exception {
228230

@@ -244,24 +246,24 @@ public void closedChannelMessage_with_nullChannel() throws Exception {
244246
@Test
245247
public void closedChannelMessage_with_nullParentChannel() throws Exception {
246248

247-
Channel channel = Mockito.mock(Channel.class);
248-
Attribute attribute = Mockito.mock(Attribute.class);
249+
Channel channel = mock(Channel.class);
250+
Attribute attribute = mock(Attribute.class);
249251
when(channel.parent()).thenReturn(null);
250-
when(channel.attr(Mockito.any())).thenReturn(attribute);
252+
when(channel.attr(any())).thenReturn(attribute);
251253

252254
assertThat(NettyUtils.closedChannelMessage(channel))
253255
.isEqualTo(NettyUtils.CLOSED_CHANNEL_ERROR_MESSAGE);
254256
}
255-
257+
256258
@Test
257259
public void closedChannelMessage_with_nullParentChannelAttribute() throws Exception {
258260

259-
Channel channel = Mockito.mock(Channel.class);
260-
Attribute attribute = Mockito.mock(Attribute.class);
261-
Channel parentChannel = Mockito.mock(Channel.class);
261+
Channel channel = mock(Channel.class);
262+
Attribute attribute = mock(Attribute.class);
263+
Channel parentChannel = mock(Channel.class);
262264
when(channel.parent()).thenReturn(parentChannel);
263-
when(channel.attr(Mockito.any())).thenReturn(attribute);
264-
when(parentChannel.attr(Mockito.any())).thenReturn(null);
265+
when(channel.attr(any())).thenReturn(attribute);
266+
when(parentChannel.attr(any())).thenReturn(null);
265267

266268
assertThat(NettyUtils.closedChannelMessage(channel))
267269
.isEqualTo(NettyUtils.CLOSED_CHANNEL_ERROR_MESSAGE);

0 commit comments

Comments
 (0)