jiacheliu3 commented on code in PR #733:
URL: https://github.com/apache/ratis/pull/733#discussion_r971473705


##########
ratis-server-api/src/main/java/org/apache/ratis/server/RaftServer.java:
##########
@@ -168,21 +172,28 @@ class Builder {
     private static Method initNewRaftServerMethod() {
       final String className = RaftServer.class.getPackage().getName() + 
".impl.ServerImplUtils";
       final Class<?>[] argClasses = {RaftPeerId.class, RaftGroup.class, 
RaftStorage.StartupOption.class,
-          StateMachine.Registry.class, RaftProperties.class, Parameters.class};
+          StateMachine.Registry.class, RaftProperties.class, Parameters.class, 
Thread.UncaughtExceptionHandler.class};
       try {
         final Class<?> clazz = ReflectionUtils.getClassByName(className);
-        return clazz.getMethod("newRaftServer", argClasses);
+        try {
+          return clazz.getMethod("newRaftServer", argClasses);
+        } catch (NoSuchMethodException e) {
+          final Class<?>[] argClassesNoExHandler = {RaftPeerId.class, 
RaftGroup.class, RaftStorage.StartupOption.class,
+              StateMachine.Registry.class, RaftProperties.class, 
Parameters.class};
+          return 
ReflectionUtils.getClassByName(className).getMethod("newRaftServer", 
argClassesNoExHandler);

Review Comment:
   Ok i misunderstood the code here. I initially thought this is to invoke user 
extensions (i.e. a user may extend `ServerImplUtils.newRaftServer()` to init a 
`RaftServer` child class), so the `newRaftServer()` signature should be kept 
the same to have backward compatibility. 
   
   Then after a while I realized `ServerImplUtils` is a `final` class so no 
extension is expected. I guess this reflection is used just to avoid importing 
`ratis-server` module (avoid circular dependency). 
   
   Therefore no backward compatibility is needed here.



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