I am porting a Netty 3 application to Netty 4. The Netty 3 application uses Attachement
to attach objects to the context.
Reading New and noteworthy in 4.0 I see Attachment has been removed and replaced with AttributeKey/AttributeMap.
The problem is this works when I run the application, but under integration testing, I get the error:
Caused by: java.lang.IllegalArgumentException: 'attr_key' is already in use
Where attr_key
is defined in a shareable Handler has follows:
private final AttributeKey<Object> ATTR_KEY = AttributeKey.newInstance("attr_key");
and then used somewhere else in the same handler class as follows:
channel.attr(ATTR_KEY).set(new Object())
Any ideas or thoughts on the recommended way to use AttributeKey/AttributeMap to prevent this error? Thanks!