CRZbulabula commented on code in PR #17735:
URL: https://github.com/apache/iotdb/pull/17735#discussion_r3279236009


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java:
##########
@@ -159,14 +293,24 @@ public void serialize(DataOutputStream stream) throws 
IOException {
             : ProcedureType.SET_TTL_PROCEDURE.getTypeCode());
     super.serialize(stream);
     ReadWriteIOUtils.write(plan.serializeToByteBuffer(), stream);
+    stream.writeBoolean(previousTTLStateCaptured);
+    stream.writeLong(previousTTL);
+    stream.writeLong(previousDatabaseWildcardTTL);
   }
 
   @Override
   public void deserialize(ByteBuffer byteBuffer) {
     super.deserialize(byteBuffer);
     try {
-      ReadWriteIOUtils.readInt(byteBuffer);
+      final int length = ReadWriteIOUtils.readInt(byteBuffer);
+      final int position = byteBuffer.position();
       this.plan = (SetTTLPlan) ConfigPhysicalPlan.Factory.create(byteBuffer);
+      byteBuffer.position(position + length);

Review Comment:
   这行 `byteBuffer.position(position + length)` 
是必要的修复(不是冗余),建议加一行注释解释原因——否则后来人很容易觉得「`Factory.create` 自己应该已经读对位置了,这行多余」就给删了。
   
   实际原因:`serializeToByteBuffer()` 用 `ByteBuffer.wrap(publicBAOS.getBuf(), 0, 
size())` 包裹,而 `ReadWriteIOUtils.write(ByteBuffer, OutputStream)` 写的是 
`byteBuffer.capacity()`(即底层数组长度,可能 > 实际数据 size),后面会跟着多余的 padding 0 字节。如果不强制 
reposition,新加的 `boolean + 2*long` 就会从 padding 区读出来。



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

Reply via email to