Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalArgumentException: 'isReleased' is already in use #1886

Closed
lanwen opened this issue Jun 10, 2020 · 2 comments · Fixed by #1887
Closed

IllegalArgumentException: 'isReleased' is already in use #1886

lanwen opened this issue Jun 10, 2020 · 2 comments · Fixed by #1887
Labels
bug This issue is a bug.

Comments

@lanwen
Copy link

lanwen commented Jun 10, 2020

Evaluation of the ReleaseOnceChannelPool in two classloaders with shared netty will lead to the exception

Caused by: java.lang.IllegalArgumentException: 'isReleased' is already in use
	at io.netty.util.ConstantPool.createOrThrow(ConstantPool.java:113)
	at io.netty.util.ConstantPool.newInstance(ConstantPool.java:95)
	at io.netty.util.AttributeKey.newInstance(AttributeKey.java:55)
	at software.amazon.awssdk.http.nio.netty.internal.ReleaseOnceChannelPool.<clinit>(ReleaseOnceChannelPool.java:38)

and

Caused by: java.lang.NoClassDefFoundError: Could not initialize class software.amazon.awssdk.http.nio.netty.internal.ReleaseOnceChannelPool
	at software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient$1.newPool(NettyNioAsyncHttpClient.java:158)
	at software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient$1.newPool(NettyNioAsyncHttpClient.java:143)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(Unknown Source)
	at software.amazon.awssdk.http.nio.netty.internal.SdkChannelPoolMap.get(SdkChannelPoolMap.java:42)

Describe the bug

We use https://github.com/pf4j/pf4j for the system with netty server serving grpc with some pluggable handlers which are sharing netty in a classpath, but have anything else within an isolated classpath. If two plugins trying to work with dynamodb, each with own copy of the sdk, second plugin will get the exception above, trying to init

https://github.com/aws/aws-sdk-java-v2/blob/master/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/ReleaseOnceChannelPool.java#L38

at the moment its a 2.13.33 version.

Expected Behavior

Each sdk have isolated init from the shared netty part. Netty is pretty big framework and embedding it into each plugin could be a great waste of memory. So would be nice to have something like classloader id on such an id.

Current Behavior

Steps to Reproduce

Create a global classloader, load netty, create a child classloader (loading first from child, then from parent), load sdk in there, call sdk. Create the second classloader same as first child, repeat the sdk call.

The project we're using is the https://github.com/bsideup/liiklus.

Possible Solution

Adding classloader id could help, so that attributes wouldn't care about others.

Context

Almost the same issue was fixed in the grpc grpc/grpc-java#6707

Your Environment

  • AWS Java SDK version used: 2.13.33
  • JDK version used: 11
  • Operating System and version: nix
@lanwen lanwen added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 10, 2020
dagnir added a commit to dagnir/aws-sdk-java-v2 that referenced this issue Jun 10, 2020
This commit prevents the Netty client from throwing an exception in cases where
it tries to declare an attribute key and the key already exists. This can happen
when separate instances of the SDK are loaded by different classloaders, but the
Netty classes loaded by a third and shared by the other classloaders.

Fixes aws#1886
@debora-ito debora-ito removed the needs-triage This issue or PR still needs to be triaged. label Jun 10, 2020
@bsideup
Copy link

bsideup commented Jun 11, 2020

@dagnir wow, impressive response timing! Thanks for fixing it so fast (and everywhere) 👍

@dagnir
Copy link
Contributor

dagnir commented Jun 11, 2020

@bsideup Happy to help!

aws-sdk-java-automation added a commit that referenced this issue Jan 5, 2022
…3936ae14c

Pull request: release <- staging/fee2472e-4bc9-4c6c-b061-6673936ae14c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants