Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/yudao-cloud
# Conflicts: # yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.javapull/150/MERGE
commit
104d94977b
|
@ -61,7 +61,13 @@
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- xss -->
|
<!-- 工具类相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<scope>provided</scope> <!-- 设置为 provided,只有工具类需要使用到 -->
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jsoup</groupId>
|
<groupId>org.jsoup</groupId>
|
||||||
<artifactId>jsoup</artifactId>
|
<artifactId>jsoup</artifactId>
|
||||||
|
|
|
@ -17,6 +17,11 @@ import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||||
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
|
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
|
||||||
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.validation.ConstraintViolation;
|
||||||
|
import jakarta.validation.ConstraintViolationException;
|
||||||
|
import jakarta.validation.ValidationException;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||||
|
@ -33,11 +38,8 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||||
|
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.ConstraintViolation;
|
|
||||||
import javax.validation.ConstraintViolationException;
|
|
||||||
import javax.validation.ValidationException;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -95,9 +97,9 @@ public class GlobalExceptionHandler {
|
||||||
if (ex instanceof NoHandlerFoundException) {
|
if (ex instanceof NoHandlerFoundException) {
|
||||||
return noHandlerFoundExceptionHandler((NoHandlerFoundException) ex);
|
return noHandlerFoundExceptionHandler((NoHandlerFoundException) ex);
|
||||||
}
|
}
|
||||||
// if (ex instanceof NoResourceFoundException) {
|
if (ex instanceof NoResourceFoundException) {
|
||||||
// return noResourceFoundExceptionHandler(request, (NoResourceFoundException) ex);
|
return noResourceFoundExceptionHandler(request, (NoResourceFoundException) ex);
|
||||||
// }
|
}
|
||||||
if (ex instanceof HttpRequestMethodNotSupportedException) {
|
if (ex instanceof HttpRequestMethodNotSupportedException) {
|
||||||
return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex);
|
return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex);
|
||||||
}
|
}
|
||||||
|
@ -110,6 +112,9 @@ public class GlobalExceptionHandler {
|
||||||
if (ex instanceof AccessDeniedException) {
|
if (ex instanceof AccessDeniedException) {
|
||||||
return accessDeniedExceptionHandler(request, (AccessDeniedException) ex);
|
return accessDeniedExceptionHandler(request, (AccessDeniedException) ex);
|
||||||
}
|
}
|
||||||
|
if (ex instanceof UncheckedExecutionException && ex.getCause() != ex) {
|
||||||
|
return allExceptionHandler(request, ex.getCause());
|
||||||
|
}
|
||||||
return defaultExceptionHandler(request, ex);
|
return defaultExceptionHandler(request, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,14 +227,14 @@ public class GlobalExceptionHandler {
|
||||||
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL()));
|
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * 处理 SpringMVC 请求地址不存在
|
* 处理 SpringMVC 请求地址不存在
|
||||||
// */
|
*/
|
||||||
// @ExceptionHandler(NoResourceFoundException.class)
|
@ExceptionHandler(NoResourceFoundException.class)
|
||||||
// private CommonResult<?> noResourceFoundExceptionHandler(HttpServletRequest req, NoResourceFoundException ex) {
|
private CommonResult<?> noResourceFoundExceptionHandler(HttpServletRequest req, NoResourceFoundException ex) {
|
||||||
// log.warn("[noResourceFoundExceptionHandler]", ex);
|
log.warn("[noResourceFoundExceptionHandler]", ex);
|
||||||
// return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getResourcePath()));
|
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getResourcePath()));
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理 SpringMVC 请求方法不正确
|
* 处理 SpringMVC 请求方法不正确
|
||||||
|
@ -265,6 +270,16 @@ public class GlobalExceptionHandler {
|
||||||
return CommonResult.error(FORBIDDEN);
|
return CommonResult.error(FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理 Guava UncheckedExecutionException
|
||||||
|
*
|
||||||
|
* 例如说,缓存加载报错,可见 <a href="https://t.zsxq.com/UszdH">https://t.zsxq.com/UszdH</a>
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(value = UncheckedExecutionException.class)
|
||||||
|
public CommonResult<?> uncheckedExecutionExceptionHandler(HttpServletRequest req, UncheckedExecutionException ex) {
|
||||||
|
return allExceptionHandler(req, ex.getCause());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理业务异常 ServiceException
|
* 处理业务异常 ServiceException
|
||||||
*
|
*
|
||||||
|
@ -343,12 +358,12 @@ public class GlobalExceptionHandler {
|
||||||
errorLog.setApplicationName(applicationName);
|
errorLog.setApplicationName(applicationName);
|
||||||
errorLog.setRequestUrl(request.getRequestURI());
|
errorLog.setRequestUrl(request.getRequestURI());
|
||||||
Map<String, Object> requestParams = MapUtil.<String, Object>builder()
|
Map<String, Object> requestParams = MapUtil.<String, Object>builder()
|
||||||
.put("query", ServletUtils.getParamMap(request))
|
.put("query", JakartaServletUtil.getParamMap(request))
|
||||||
.put("body", ServletUtils.getBody(request)).build();
|
.put("body", JakartaServletUtil.getBody(request)).build();
|
||||||
errorLog.setRequestParams(JsonUtils.toJsonString(requestParams));
|
errorLog.setRequestParams(JsonUtils.toJsonString(requestParams));
|
||||||
errorLog.setRequestMethod(request.getMethod());
|
errorLog.setRequestMethod(request.getMethod());
|
||||||
errorLog.setUserAgent(ServletUtils.getUserAgent(request));
|
errorLog.setUserAgent(ServletUtils.getUserAgent(request));
|
||||||
errorLog.setUserIp(ServletUtils.getClientIP(request));
|
errorLog.setUserIp(JakartaServletUtil.getClientIP(request));
|
||||||
errorLog.setExceptionTime(LocalDateTime.now());
|
errorLog.setExceptionTime(LocalDateTime.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@ import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCand
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.flowable.bpmn.model.Activity;
|
import org.flowable.bpmn.model.*;
|
||||||
import org.flowable.bpmn.model.CallActivity;
|
|
||||||
import org.flowable.bpmn.model.FlowElement;
|
|
||||||
import org.flowable.bpmn.model.UserTask;
|
|
||||||
import org.flowable.engine.delegate.DelegateExecution;
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
|
import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
|
||||||
import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior;
|
import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior;
|
||||||
|
@ -85,6 +82,12 @@ public class BpmSequentialMultiInstanceBehavior extends SequentialMultiInstanceB
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void executeOriginalBehavior(DelegateExecution execution, ExecutionEntity multiInstanceRootExecution, int loopCounter) {
|
protected void executeOriginalBehavior(DelegateExecution execution, ExecutionEntity multiInstanceRootExecution, int loopCounter) {
|
||||||
|
// 参见 https://t.zsxq.com/53Meo 情况
|
||||||
|
if (execution.getCurrentFlowElement() instanceof CallActivity
|
||||||
|
|| execution.getCurrentFlowElement() instanceof SubProcess) {
|
||||||
|
super.executeOriginalBehavior(execution, multiInstanceRootExecution, loopCounter);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 参见 https://gitee.com/zhijiantianya/yudao-cloud/issues/IC239F
|
// 参见 https://gitee.com/zhijiantianya/yudao-cloud/issues/IC239F
|
||||||
super.collectionExpression = null;
|
super.collectionExpression = null;
|
||||||
super.collectionVariable = FlowableUtils.formatExecutionCollectionVariable(execution.getCurrentActivityId());
|
super.collectionVariable = FlowableUtils.formatExecutionCollectionVariable(execution.getCurrentActivityId());
|
||||||
|
|
|
@ -21,6 +21,16 @@ tenant-id: {{adminTenantId}}
|
||||||
"password": "admin123"
|
"password": "admin123"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### 请求 /login 接口 => 失败(租户不存在)
|
||||||
|
POST {{baseUrl}}/system/auth/login
|
||||||
|
Content-Type: application/json
|
||||||
|
tenant-id: 2
|
||||||
|
|
||||||
|
{
|
||||||
|
"username": "admin",
|
||||||
|
"password": "admin123"
|
||||||
|
}
|
||||||
|
|
||||||
### 请求 /get-permission-info 接口 => 成功
|
### 请求 /get-permission-info 接口 => 成功
|
||||||
GET {{baseUrl}}/system/auth/get-permission-info
|
GET {{baseUrl}}/system/auth/get-permission-info
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
Loading…
Reference in New Issue