Details
-
Bug
-
Status: Needs Committer
-
Normal
-
Resolution: Unresolved
-
None
-
None
-
Code - Bug - Unclear Impact
-
Low
-
Low Hanging Fruit
-
User Report
-
All
-
None
-
Description
The java driver uses netty channel attributes to decorate a connection's channel with the cluster name (returned from the system.local table) and the map from the OPTIONS response, both of which are obtained on connection initialization.
There's an issue here that I wouldn't expect to see in practice in that the AttributeKey's used are created using AttributeKey.newInstance, which throws an exception if an AttributeKey of that name is defined anywhere else in evaluated code.
static final AttributeKey<String> CLUSTER_NAME_KEY = AttributeKey.newInstance("cluster_name"); static final AttributeKey<Map<String, List<String>>> OPTIONS_KEY = AttributeKey.newInstance("options");
This was encountered by a user that was creating driver connections within a trigger: https://the-asf.slack.com/archives/CJZLTM05A/p1705537114305579
Caused by: java.lang.IllegalArgumentException: 'cluster_name' is already in use at io.netty.util.ConstantPool.createOrThrow(ConstantPool.java:109) at io.netty.util.ConstantPool.newInstance(ConstantPool.java:91) at io.netty.util.AttributeKey.newInstance(AttributeKey.java:55) at com.datastax.oss.driver.internal.core.channel.DriverChannel.<clinit>(DriverChannel.java:50) ... 30 common frames omitted
There is likely some class loading oddness in the Trigger implementation that exacerbates the problem. But at the least, if the driver were to use AttributeKey.valueOf instead (like Cassandra does where it uses them: https://github.com/search?q=repo%3Aapache%2Fcassandra+AttributeKey.valueOf&type=code), this particular issue could be avoided.
Debatably we could use valueOf(firstNameComponent,secondNameComponent) as a way of namespacing the attribute (e.g. AttributeKey.newInstance("com.datastax.oss.driver.internal.core.channel", "cluster_name");, this does not seem necessary though.
Attachments
Issue Links
- links to