adoroszlai commented on code in PR #7914:
URL: https://github.com/apache/ozone/pull/7914#discussion_r1961858033
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMRatisServerImpl.java:
##########
@@ -429,4 +430,14 @@ public RaftPeer getLeader() {
division.getRaftConf().getPeer(RaftPeerId.valueOf(leaderId));
}
}
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getProxyHandler(final RequestType type, final Class<T> intf,
final T impl) {
+ final SCMHAInvocationHandler invocationHandler =
+ new SCMHAInvocationHandler(type, impl, this);
+ return (T) Proxy.newProxyInstance(getClass().getClassLoader(),
+ new Class<?>[] {intf}, invocationHandler);
+ }
Review Comment:
- This can be moved to `SCMRatisServer` as `default` method, then we don't
need to duplicate in `SCMHAManagerStub`.
- Suppressed unchecked warning can be fixed by replacing `(T)` with:
`intf.cast(...)`.
- ~Should we keep using `SCMHAInvocationHandler.class.getClassLoader()`?
(In practice I don't think these would give different results.)~ I guess
getting own class' loader is better, the old one may result in
`SecurityException`.
--
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]