slfan1989 commented on code in PR #1354:
URL: https://github.com/apache/ratis/pull/1354#discussion_r2826937532


##########
ratis-common/src/main/java/org/apache/ratis/retry/RetryPolicy.java:
##########
@@ -95,7 +96,31 @@ static RetryPolicy parse(String commaSeparated) {
           .setMaxAttempts(Integer.parseInt(args[3].trim()))
           .build();
     }
+    if (classname.equals(MultipleLinearRandomRetry.class.getSimpleName())) {
+      if (args.length == 1) {
+        throw new IllegalArgumentException("Failed to parse 
MultipleLinearRandomRetry: args.length = "
+            + args.length + " <= 1 for " + commaSeparated);
+      }
+      final String params = String.join(",", Arrays.copyOfRange(args, 1, 
args.length));
+      return MultipleLinearRandomRetry.parseCommaSeparated(params);
+    }
+    // Backward compatibility: legacy config omits class name and starts with 
a duration (e.g. "1ms").
+    if (isLegacyMultipleLinearRandomRetryParams(classname)) {
+      return MultipleLinearRandomRetry.parseCommaSeparated(commaSeparated);
+    }
+    // If a class name is present but unknown, fail fast to surface config 
errors.
     throw new IllegalArgumentException("Failed to parse RetryPolicy: unknown 
class "
         + args[0] + " for " + commaSeparated);
   }
+
+  static boolean isLegacyMultipleLinearRandomRetryParams(String firstElement) {
+    // The legacy format starts with a duration token, not a class name.
+    final String trimmed = firstElement.trim().replace("_", "");

Review Comment:
   Agree with your point. The code has been updated accordingly.



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