Russole commented on PR #9919:
URL: https://github.com/apache/ozone/pull/9919#issuecomment-4068118220
Thanks @szetszwo for the review. This approach works.
To make the acceptence(cert-rotation) tests pass, I added a small adjustment
when determining the element type. In some cases the runtime element class is
not exactly the same as the class registered in ScmCodecFactory, even though
the registered type is compatible.
For example, the runtime element may be a subclass of a registered codec
type. So instead of directly using elements.get(0).getClass(), I resolve the
registered class using isAssignableFrom:
```
Class<?> runtimeClass = elements.get(0).getClass();
Class<?> registeredClass = null;
for (Class<?> clazz : classes.values()) {
if (clazz.isAssignableFrom(runtimeClass)) {
registeredClass = clazz;
break;
}
}
if (registeredClass == null) {
throw new InvalidProtocolBufferException(
"Unsupported list element type: " + runtimeClass.getName());
}
final String elementType = registeredClass.getName();
```
This ensures we always use the registered codec type even if the runtime
element class differs slightly.
--
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]