deason 2 лет назад
Родитель
Сommit
0b7b9598df

+ 7 - 1
examcloud-web/src/main/java/cn/com/qmth/examcloud/web/interceptor/FirstInterceptor.java

@@ -1,5 +1,6 @@
 package cn.com.qmth.examcloud.web.interceptor;
 
+import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.util.JsonUtil;
 import cn.com.qmth.examcloud.commons.util.ThreadLocalUtil;
 import cn.com.qmth.examcloud.web.enums.HttpServletRequestAttribute;
@@ -75,13 +76,18 @@ public class FirstInterceptor implements HandlerInterceptor {
             HandlerMethod handlerMethod = (HandlerMethod) handler;
             ApiId apiId = handlerMethod.getMethodAnnotation(ApiId.class);
 
-            ApiInfo apiInfo = null;
+            ApiInfo apiInfo;
             if (null != apiId) {
                 apiInfo = ApiInfoHolder.getApiInfo(apiId.value());
             } else {
                 apiInfo = ApiInfoHolder.getApiInfo(handlerMethod.getMethod());
             }
 
+            if (apiInfo == null) {
+                LOG.error("path:{} method:{} apiInfo is null.", path, method);
+                throw new StatusException("请求信息异常!");
+            }
+
             String mapping = apiInfo.getMapping();
             request.setAttribute(HttpServletRequestAttribute.$_API_INFO.name(), apiInfo);