slfan1989 commented on code in PR #4594:
URL: https://github.com/apache/hadoop/pull/4594#discussion_r930730069


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServices.java:
##########
@@ -206,50 +179,20 @@ protected Map<String, RequestInterceptorChainWrapper> 
getPipelines() {
    */
   @VisibleForTesting
   protected RESTRequestInterceptor createRequestInterceptorChain() {
-
-    List<String> interceptorClassNames = getInterceptorClassNames(conf);
-
-    RESTRequestInterceptor pipeline = null;
-    RESTRequestInterceptor current = null;
-    for (String interceptorClassName : interceptorClassNames) {
-      try {
-        Class<?> interceptorClass = conf.getClassByName(interceptorClassName);
-        if (RESTRequestInterceptor.class.isAssignableFrom(interceptorClass)) {
-          RESTRequestInterceptor interceptorInstance =
-              (RESTRequestInterceptor) ReflectionUtils
-                  .newInstance(interceptorClass, conf);
-          if (pipeline == null) {
-            pipeline = interceptorInstance;
-            current = interceptorInstance;
-            continue;
-          } else {
-            current.setNextInterceptor(interceptorInstance);
-            current = interceptorInstance;
-          }
-        } else {
-          throw new YarnRuntimeException(
-              "Class: " + interceptorClassName + " not instance of "
-                  + RESTRequestInterceptor.class.getCanonicalName());
-        }
-      } catch (ClassNotFoundException e) {
-        throw new YarnRuntimeException(
-            "Could not instantiate RESTRequestInterceptor: "
-                + interceptorClassName,
-            e);
-      }
-    }
-
-    if (pipeline == null) {
-      throw new YarnRuntimeException(
-          "RequestInterceptor pipeline is not configured in the system");
+    try {
+      return RouterServerUtil.createRequestInterceptorChain(conf,
+          YarnConfiguration.ROUTER_WEBAPP_INTERCEPTOR_CLASS_PIPELINE,
+          YarnConfiguration.DEFAULT_ROUTER_WEBAPP_INTERCEPTOR_CLASS,
+          RESTRequestInterceptor.class);
+    } catch (YarnRuntimeException ex) {
+      throw new YarnRuntimeException("Create RequestInterceptor Chain error.", 
ex);

Review Comment:
   I will modify the code to remove the try catch.



-- 
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: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to