Russole commented on code in PR #10690:
URL: https://github.com/apache/ozone/pull/10690#discussion_r3549730269
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/io/ScmListCodec.java:
##########
@@ -69,6 +69,12 @@ public Object deserialize(ByteString value) throws
InvalidProtocolBufferExceptio
"Missing ListArgument.type: " + argument);
}
+ // Empty list was serialized with type=Object.class.getName() as a
sentinel.
+ // Skip element-type resolution — there are no elements to decode.
+ if (argument.getValueCount() == 0) {
+ return new ArrayList<>();
Review Comment:
I think returning `Collections.emptyList()` can break replay for replicated
methods whose parameter type is `ArrayList`.
For example, `DeletedBlockLogStateManager` declares methods like
`addTransactionsToDB(ArrayList<DeletedBlocksTransaction> txs, ...)`. During
decode, `SCMRatisRequest.decode()` stores the deserialized list in the
`Object[]` arguments, and the generated `DeletedBlockLogStateManagerInvoker`
later casts it back with `(ArrayList) p[0]`.
For non-empty lists, `ScmListCodec.deserialize()` returns a new `ArrayList`,
so the cast works. With this change, empty lists return
`Collections.emptyList()` (`Collections$EmptyList`), which is not an
`ArrayList`, so replay can fail with `ClassCastException`.
Should this return `new ArrayList<>()` instead to preserve the runtime type
expected by the existing generated invokers?
--
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]