aws / aws/aws-sdk-java-v2

Blocking call inside of a software.amazon.awssdk.http.nio.netty.internal.BetterSimpleChannelPool.close

Open
#2,145 4 comments 4 reactions 0 assignees View on GitHub
feature-request p3
Dominant language
Java
Stars
2.6k
Forks
1k
Avg merge
2d 9h
Merged PRs (30d)
51

Description

Since v2 is claimed to be non-blocking, we still facing a blocking call in `software.amazon.awssdk.http.nio.netty.internal.BetterSimpleChannelPool#close` which could be concidered as illegal in this case.
We use https://github.com/reactor/BlockHound in pair with Reactor in spring as well as localstack in testcontainers in our tests, where this blocking call is popping out.

## Describe the issue
We see in test logs this stacktrace:

```java
2020-11-13 11:15:00.917 WARN 63962 --- [entExecutor-2-1] i.n.util.concurrent.GlobalEventExecutor : Unexpected exception from the global event executor:

reactor.blockhound.BlockingOperationError: Blocking call! java.lang.Object#wait
at java.base/java.lang.Object.wait(Object.java)
at java.base/java.lang.Object.wait(Object.java:321)
at io.netty.util.concurrent.DefaultPromise.awaitUninterruptibly(DefaultPromise.java:274)
at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:137)
at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:30)
at io.netty.channel.pool.SimpleChannelPool.close(SimpleChannelPool.java:402)
at software.amazon.awssdk.http.nio.netty.internal.BetterSimpleChannelPool.close(BetterSimpleChannelPool.java:38)
at software.amazon.awssdk.http.nio.netty.internal.HonorCloseOnReleaseChannelPool.close(HonorCloseOnReleaseChannelPool.java:75)
at software.amazon.awssdk.http.nio.netty.internal.IdleConnectionCountingChannelPool.close(IdleConnectionCountingChannelPool.java:106)
at software.amazon.awssdk.http.nio.netty.internal.utils.BetterFixedChannelPool.lambda$close0$3(BetterFixedChannelPool.java:391)
at io.netty.util.concurrent.GlobalEventExecutor$TaskRunner.run(GlobalEventExecutor.java:243)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:832)

2020-11-13 11:15:05.917 ERROR 63962 --- [extShutdownHook] s.a.a.h.n.netty.NettyNioAsyncHttpClient : Unable to close channel pools
```

## Steps to Reproduce
It's hard actually to reproduce the issue, as it's visible or affecting test execution not 100% of the times.

However we're doing in tests something really simple like
```java
var client = DynamoDbEnhancedAsyncClient.builder().dynamoDbClient(DynamoDbAsyncClient.builder().build()).build();
dynamoDb.table("table-name", TableSchema.fromBean(Content.class)).createTable()/.query()
```

within the test. Later when the context closes (we defined clients as spring beans), the close method seems to be called.

## Current Behavior

`BetterSimpleChannelPool#close` blocks the thread

## Your Environment

* AWS Java SDK version used: 2.15.26
* JDK version used: 1.14
* Operating System and version: any

Current workaround is to whitelist this in the BlockHound
```java
.allowBlockingCallsInside(
"software.amazon.awssdk.http.nio.netty.internal.BetterSimpleChannelPool",
"close"
)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.