olim7t commented on code in PR #2037:
URL:
https://github.com/apache/cassandra-java-driver/pull/2037#discussion_r2064962744
##########
core/src/main/java/com/datastax/oss/driver/internal/core/cql/CqlRequestHandler.java:
##########
@@ -248,6 +259,16 @@ private void sendRequest(
if (result.isDone()) {
return;
}
+ String nodeRequestId =
this.distributedTraceIdGenerator.getNodeRequestId(statement, logPrefix);
+ if (!this.customPayloadKey.isEmpty()) {
+ // We cannot do statement.getCustomPayload().put() because the default
empty map is abstract
+ // But this will create new Statement instance for every request. We
might want to optimize
+ // this
+ Map<String, ByteBuffer> existingMap = new
HashMap<>(statement.getCustomPayload());
Review Comment:
I think you can copy just the payload, not the whole statement:
```java
Map<String, ByteBuffer> customPayload = statement.getCustomPayload();
if (!this.customPayloadKey.isEmpty()) {
customPayload =
NullAllowingImmutableMap.<String, ByteBuffer>builder()
.putAll(customPayload)
.put(
this.customPayloadKey,
ByteBuffer.wrap(nodeRequestId.getBytes(StandardCharsets.UTF_8)))
.build();
}
```
Then modify line 307 like so:
```diff
channel
- .write(message, statement.isTracing(),
statement.getCustomPayload(), nodeResponseCallback)
+ .write(message, statement.isTracing(), customPayload,
nodeResponseCallback)
.addListener(nodeResponseCallback);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]