yu199195 commented on code in PR #4165:
URL: https://github.com/apache/shenyu/pull/4165#discussion_r1017341345


##########
shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/client/AbstractShenyuSdkClient.java:
##########
@@ -89,16 +95,39 @@ public void init(final RegisterConfig registerConfig, final 
ShenyuInstanceRegist
         this.registerConfig = registerConfig;
         this.registerRepository = instanceRegisterRepository;
         Properties props = registerConfig.getProps();
-        Boolean retryEnable = 
Optional.ofNullable(props.get("retry.enable")).map(e -> (boolean) 
e).orElse(false);
-        Long period = Optional.ofNullable(props.get("retry.period")).map(l -> 
(Long) l).orElse(100L);
-        long maxPeriod = 
Optional.ofNullable(props.get("retry.maxPeriod")).map(l -> (Long) 
l).orElse(SECONDS.toMillis(1));
-        int maxAttempts = 
Optional.ofNullable(props.get("retry.maxAttempts")).map(l -> (int) l).orElse(5);
+        Boolean retryEnable = 
Optional.ofNullable(props.get("retry.enable")).map(e -> 
Boolean.parseBoolean(e.toString())).orElse(false);
+        Long period = Optional.ofNullable(props.get("retry.period")).map(l -> 
Long.parseLong(l.toString())).orElse(100L);
+        long maxPeriod = 
Optional.ofNullable(props.get("retry.maxPeriod")).map(l -> 
Long.parseLong(l.toString())).orElse(SECONDS.toMillis(1));
+        int maxAttempts = 
Optional.ofNullable(props.get("retry.maxAttempts")).map(l -> 
Integer.parseInt(l.toString())).orElse(5);
         this.algorithm = props.getProperty("algorithm", "roundRobin");
         this.scheme = props.getProperty("scheme", "http");
         this.retryer = retryEnable ? new Retryer.DefaultRetry(period, 
maxPeriod, maxAttempts) : Retryer.NEVER_RETRY;
+        this.initRequestInterceptors(registerConfig);
         this.initClient(props);
     }
 
+    private void initRequestInterceptors(final RegisterConfig registerConfig) {
+        boolean requestInterceptorEnable = 
Optional.ofNullable(registerConfig.getProps().get("requestInterceptor.enable")).map(e
 -> Boolean.parseBoolean(e.toString())).orElse(false);
+        Object requestInterceptorClass;
+        int listIdx = 0;
+        try {
+            if (requestInterceptorEnable) {
+                while ((requestInterceptorClass = 
registerConfig.getProps().get("requestInterceptor.classes." + listIdx)) != 
null) {
+                    Class<?> aClass = 
ClassUtils.getClass(requestInterceptorClass.toString());
+                    Type[] genericInterfaces = aClass.getGenericInterfaces();
+                    for (Type type : genericInterfaces) {
+                        if 
(type.getTypeName().equals(ShenyuSdkRequestInterceptor.class.getTypeName())) {
+                            
requestInterceptors.add((ShenyuSdkRequestInterceptor) aClass.newInstance());

Review Comment:
   if requestInterceptor is spring bean or  there are dependencies inside? this 
can creater?



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