absurdfarce commented on code in PR #1909:
URL: 
https://github.com/apache/cassandra-java-driver/pull/1909#discussion_r1476798500


##########
core/src/main/java/com/datastax/oss/driver/internal/core/type/codec/VectorCodec.java:
##########
@@ -127,17 +127,19 @@ Elements should at least precede themselves with their 
size (along the lines of
               cqlType.getDimensions(), bytes.remaining()));
     }
 
+    ByteBuffer slice = bytes.slice();
     List<SubtypeT> rv = new ArrayList<SubtypeT>(cqlType.getDimensions());
     for (int i = 0; i < cqlType.getDimensions(); ++i) {
-      ByteBuffer slice = bytes.slice();
-      slice.limit(elementSize);
+      // Set the limit for the current element
+      int originalPosition = slice.position();
+      slice.limit(originalPosition + elementSize);
       rv.add(this.subtypeCodec.decode(slice, protocolVersion));
-      bytes.position(bytes.position() + elementSize);
+      // Move to the start of the next element
+      slice.position(originalPosition + elementSize);

Review Comment:
   Just an observation: this would cause us to miss elements (possibly 
silently) for subtypes which have a codec that consumes the input ByteBuffer.  
I'm pretty sure this isn't the only composite/collection codec that that's true 
for, however, and any such subtype codec would have to ignore the [explicit 
guidance](https://docs.datastax.com/en/drivers/java/4.17/com/datastax/oss/driver/api/core/type/codec/TypeCodec.html)
 on TypeCodec Javadoc anyways... so we're already in a misbehaving world in 
that case.



-- 
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]

Reply via email to