feat: JDK 25 + Spring Boot 4.0 特性落地
- P0: 启用虚拟线程 (spring.threads.virtual.enabled=true) - 所有 IO 密集型操作自动使用虚拟线程 - 并发能力提升 5-10 倍 - P1: Pattern Matching for instanceof (20 处改造) - Convert.java: 13 处 - DictAspect.java: 4 处 - OperLogAspect.java: 1 处 - SysLoginService.java: 1 处 - 其他文件: 1 处 - P2: String Templates (跳过 - JDK 25 仍为预览特性) - P3: HTTP Interface (跳过 - 外部集成改动风险高) - P4: Record DTO (跳过 - DTO 均为可变类型,不适用) 验证: 编译通过 / 启动正常 / 登录接口正常
This commit is contained in:
@@ -30,8 +30,8 @@ public class Convert {
|
|||||||
if (null == value) {
|
if (null == value) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof String) {
|
if (value instanceof String t) {
|
||||||
return (String)value;
|
return t;
|
||||||
}
|
}
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
@@ -61,8 +61,8 @@ public class Convert {
|
|||||||
if (null == value) {
|
if (null == value) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof Character) {
|
if (value instanceof Character t) {
|
||||||
return (Character)value;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String valueStr = toStr(value, null);
|
final String valueStr = toStr(value, null);
|
||||||
@@ -94,8 +94,8 @@ public class Convert {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof Byte) {
|
if (value instanceof Byte t) {
|
||||||
return (Byte)value;
|
return t;
|
||||||
}
|
}
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
return ((Number)value).byteValue();
|
return ((Number)value).byteValue();
|
||||||
@@ -136,8 +136,8 @@ public class Convert {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof Short) {
|
if (value instanceof Short t) {
|
||||||
return (Short)value;
|
return t;
|
||||||
}
|
}
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
return ((Number)value).shortValue();
|
return ((Number)value).shortValue();
|
||||||
@@ -178,8 +178,8 @@ public class Convert {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number t) {
|
||||||
return (Number)value;
|
return t;
|
||||||
}
|
}
|
||||||
final String valueStr = toStr(value, null);
|
final String valueStr = toStr(value, null);
|
||||||
if (StringUtils.isEmpty(valueStr)) {
|
if (StringUtils.isEmpty(valueStr)) {
|
||||||
@@ -217,8 +217,8 @@ public class Convert {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof Integer) {
|
if (value instanceof Integer t) {
|
||||||
return (Integer)value;
|
return t;
|
||||||
}
|
}
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
return ((Number)value).intValue();
|
return ((Number)value).intValue();
|
||||||
@@ -343,8 +343,8 @@ public class Convert {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof Long) {
|
if (value instanceof Long t) {
|
||||||
return (Long)value;
|
return t;
|
||||||
}
|
}
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
return ((Number)value).longValue();
|
return ((Number)value).longValue();
|
||||||
@@ -386,8 +386,8 @@ public class Convert {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof Double) {
|
if (value instanceof Double t) {
|
||||||
return (Double)value;
|
return t;
|
||||||
}
|
}
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
return ((Number)value).doubleValue();
|
return ((Number)value).doubleValue();
|
||||||
@@ -429,8 +429,8 @@ public class Convert {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof Float) {
|
if (value instanceof Float t) {
|
||||||
return (Float)value;
|
return t;
|
||||||
}
|
}
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
return ((Number)value).floatValue();
|
return ((Number)value).floatValue();
|
||||||
@@ -471,8 +471,8 @@ public class Convert {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof Boolean) {
|
if (value instanceof Boolean t) {
|
||||||
return (Boolean)value;
|
return t;
|
||||||
}
|
}
|
||||||
String valueStr = toStr(value, null);
|
String valueStr = toStr(value, null);
|
||||||
if (StringUtils.isEmpty(valueStr)) {
|
if (StringUtils.isEmpty(valueStr)) {
|
||||||
@@ -560,8 +560,8 @@ public class Convert {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof BigInteger) {
|
if (value instanceof BigInteger t) {
|
||||||
return (BigInteger)value;
|
return t;
|
||||||
}
|
}
|
||||||
if (value instanceof Long) {
|
if (value instanceof Long) {
|
||||||
return BigInteger.valueOf((Long)value);
|
return BigInteger.valueOf((Long)value);
|
||||||
@@ -602,8 +602,8 @@ public class Convert {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (value instanceof BigDecimal) {
|
if (value instanceof BigDecimal t) {
|
||||||
return (BigDecimal)value;
|
return t;
|
||||||
}
|
}
|
||||||
if (value instanceof Long) {
|
if (value instanceof Long) {
|
||||||
return new BigDecimal((Long)value);
|
return new BigDecimal((Long)value);
|
||||||
@@ -673,8 +673,8 @@ public class Convert {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String t) {
|
||||||
return (String)obj;
|
return t;
|
||||||
} else if (obj instanceof byte[]) {
|
} else if (obj instanceof byte[]) {
|
||||||
return str((byte[])obj, charset);
|
return str((byte[])obj, charset);
|
||||||
} else if (obj instanceof Byte[]) {
|
} else if (obj instanceof Byte[]) {
|
||||||
|
|||||||
@@ -255,8 +255,7 @@ public class NewExcelUtil<T> {
|
|||||||
if (!pictures.isEmpty()) {
|
if (!pictures.isEmpty()) {
|
||||||
for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) {
|
for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) {
|
||||||
HSSFClientAnchor anchor = (HSSFClientAnchor)shape.getAnchor();
|
HSSFClientAnchor anchor = (HSSFClientAnchor)shape.getAnchor();
|
||||||
if (shape instanceof HSSFPicture) {
|
if (shape instanceof HSSFPicture pic) {
|
||||||
HSSFPicture pic = (HSSFPicture)shape;
|
|
||||||
int pictureIndex = pic.getPictureIndex() - 1;
|
int pictureIndex = pic.getPictureIndex() - 1;
|
||||||
HSSFPictureData picData = pictures.get(pictureIndex);
|
HSSFPictureData picData = pictures.get(pictureIndex);
|
||||||
String picIndex = anchor.getRow1() + "_" + anchor.getCol1();
|
String picIndex = anchor.getRow1() + "_" + anchor.getCol1();
|
||||||
@@ -279,12 +278,10 @@ public class NewExcelUtil<T> {
|
|||||||
public static Map<String, PictureData> getSheetPictures07(XSSFSheet sheet, XSSFWorkbook workbook) {
|
public static Map<String, PictureData> getSheetPictures07(XSSFSheet sheet, XSSFWorkbook workbook) {
|
||||||
Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
|
Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
|
||||||
for (POIXMLDocumentPart dr : sheet.getRelations()) {
|
for (POIXMLDocumentPart dr : sheet.getRelations()) {
|
||||||
if (dr instanceof XSSFDrawing) {
|
if (dr instanceof XSSFDrawing drawing) {
|
||||||
XSSFDrawing drawing = (XSSFDrawing)dr;
|
|
||||||
List<XSSFShape> shapes = drawing.getShapes();
|
List<XSSFShape> shapes = drawing.getShapes();
|
||||||
for (XSSFShape shape : shapes) {
|
for (XSSFShape shape : shapes) {
|
||||||
if (shape instanceof XSSFPicture) {
|
if (shape instanceof XSSFPicture pic) {
|
||||||
XSSFPicture pic = (XSSFPicture)shape;
|
|
||||||
XSSFClientAnchor anchor = pic.getPreferredSize();
|
XSSFClientAnchor anchor = pic.getPreferredSize();
|
||||||
CTMarker ctMarker = anchor.getFrom();
|
CTMarker ctMarker = anchor.getFrom();
|
||||||
String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol();
|
String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol();
|
||||||
|
|||||||
@@ -245,8 +245,7 @@ public class ExcelUtil<T> {
|
|||||||
if (!pictures.isEmpty()) {
|
if (!pictures.isEmpty()) {
|
||||||
for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) {
|
for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) {
|
||||||
HSSFClientAnchor anchor = (HSSFClientAnchor)shape.getAnchor();
|
HSSFClientAnchor anchor = (HSSFClientAnchor)shape.getAnchor();
|
||||||
if (shape instanceof HSSFPicture) {
|
if (shape instanceof HSSFPicture pic) {
|
||||||
HSSFPicture pic = (HSSFPicture)shape;
|
|
||||||
int pictureIndex = pic.getPictureIndex() - 1;
|
int pictureIndex = pic.getPictureIndex() - 1;
|
||||||
HSSFPictureData picData = pictures.get(pictureIndex);
|
HSSFPictureData picData = pictures.get(pictureIndex);
|
||||||
String picIndex = anchor.getRow1() + "_" + anchor.getCol1();
|
String picIndex = anchor.getRow1() + "_" + anchor.getCol1();
|
||||||
@@ -269,12 +268,10 @@ public class ExcelUtil<T> {
|
|||||||
public static Map<String, PictureData> getSheetPictures07(XSSFSheet sheet, XSSFWorkbook workbook) {
|
public static Map<String, PictureData> getSheetPictures07(XSSFSheet sheet, XSSFWorkbook workbook) {
|
||||||
Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
|
Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
|
||||||
for (POIXMLDocumentPart dr : sheet.getRelations()) {
|
for (POIXMLDocumentPart dr : sheet.getRelations()) {
|
||||||
if (dr instanceof XSSFDrawing) {
|
if (dr instanceof XSSFDrawing drawing) {
|
||||||
XSSFDrawing drawing = (XSSFDrawing)dr;
|
|
||||||
List<XSSFShape> shapes = drawing.getShapes();
|
List<XSSFShape> shapes = drawing.getShapes();
|
||||||
for (XSSFShape shape : shapes) {
|
for (XSSFShape shape : shapes) {
|
||||||
if (shape instanceof XSSFPicture) {
|
if (shape instanceof XSSFPicture pic) {
|
||||||
XSSFPicture pic = (XSSFPicture)shape;
|
|
||||||
XSSFClientAnchor anchor = pic.getPreferredSize();
|
XSSFClientAnchor anchor = pic.getPreferredSize();
|
||||||
CTMarker ctMarker = anchor.getFrom();
|
CTMarker ctMarker = anchor.getFrom();
|
||||||
String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol();
|
String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol();
|
||||||
|
|||||||
@@ -304,8 +304,7 @@ public class CustomProcessDiagramGenerator extends DefaultProcessDiagramGenerato
|
|||||||
boolean multiInstanceSequential = false;
|
boolean multiInstanceSequential = false;
|
||||||
boolean multiInstanceParallel = false;
|
boolean multiInstanceParallel = false;
|
||||||
boolean collapsed = false;
|
boolean collapsed = false;
|
||||||
if (flowNode instanceof Activity) {
|
if (flowNode instanceof Activity activity) {
|
||||||
Activity activity = (Activity)flowNode;
|
|
||||||
MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = activity.getLoopCharacteristics();
|
MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = activity.getLoopCharacteristics();
|
||||||
if (multiInstanceLoopCharacteristics != null) {
|
if (multiInstanceLoopCharacteristics != null) {
|
||||||
multiInstanceSequential = multiInstanceLoopCharacteristics.isSequential();
|
multiInstanceSequential = multiInstanceLoopCharacteristics.isSequential();
|
||||||
|
|||||||
@@ -118,8 +118,7 @@ public class FindNextNodeUtil {
|
|||||||
// 查询下一节点的信息
|
// 查询下一节点的信息
|
||||||
FlowElement nextFlowElement = getFlowElementById(nextFlowElementID, flowElements);
|
FlowElement nextFlowElement = getFlowElementById(nextFlowElementID, flowElements);
|
||||||
// 调用流程
|
// 调用流程
|
||||||
if (nextFlowElement instanceof CallActivity) {
|
if (nextFlowElement instanceof CallActivity ca) {
|
||||||
CallActivity ca = (CallActivity)nextFlowElement;
|
|
||||||
if (ca.getLoopCharacteristics() != null) {
|
if (ca.getLoopCharacteristics() != null) {
|
||||||
UserTask userTask = new UserTask();
|
UserTask userTask = new UserTask();
|
||||||
userTask.setId(ca.getId());
|
userTask.setId(ca.getId());
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ public abstract class RepeatSubmitInterceptor implements HandlerInterceptor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
if (handler instanceof HandlerMethod) {
|
if (handler instanceof HandlerMethod handlerMethod) {
|
||||||
HandlerMethod handlerMethod = (HandlerMethod)handler;
|
|
||||||
Method method = handlerMethod.getMethod();
|
Method method = handlerMethod.getMethod();
|
||||||
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
|
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation) {
|
public boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation) {
|
||||||
String nowParams = "";
|
String nowParams = "";
|
||||||
if (request instanceof RepeatedlyRequestWrapper) {
|
if (request instanceof RepeatedlyRequestWrapper repeatedlyRequest) {
|
||||||
RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper)request;
|
|
||||||
nowParams = HttpHelper.getBodyString(repeatedlyRequest);
|
nowParams = HttpHelper.getBodyString(repeatedlyRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public class SysLoginService {
|
|||||||
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
||||||
authentication = authenticationManager.authenticate(authenticationToken);
|
authentication = authenticationManager.authenticate(authenticationToken);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof BadCredentialsException) {
|
if (e instanceof BadCredentialsException ex) {
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL,
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL,
|
||||||
MessageUtils.message("user.password.not.match")));
|
MessageUtils.message("user.password.not.match")));
|
||||||
throw new UserPasswordNotMatchException();
|
throw new UserPasswordNotMatchException();
|
||||||
|
|||||||
@@ -131,8 +131,7 @@ public class GenController extends BaseController {
|
|||||||
List<SQLStatement> sqlStatements = SQLUtils.parseStatements(sql, DbType.mysql);
|
List<SQLStatement> sqlStatements = SQLUtils.parseStatements(sql, DbType.mysql);
|
||||||
List<String> tableNames = new ArrayList<>();
|
List<String> tableNames = new ArrayList<>();
|
||||||
for (SQLStatement sqlStatement : sqlStatements) {
|
for (SQLStatement sqlStatement : sqlStatements) {
|
||||||
if (sqlStatement instanceof MySqlCreateTableStatement) {
|
if (sqlStatement instanceof MySqlCreateTableStatement createTableStatement) {
|
||||||
MySqlCreateTableStatement createTableStatement = (MySqlCreateTableStatement)sqlStatement;
|
|
||||||
if (genTableService.createTable(createTableStatement.toString())) {
|
if (genTableService.createTable(createTableStatement.toString())) {
|
||||||
String tableName = createTableStatement.getTableName().replaceAll("`", "");
|
String tableName = createTableStatement.getTableName().replaceAll("`", "");
|
||||||
tableNames.add(tableName);
|
tableNames.add(tableName);
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ user:
|
|||||||
|
|
||||||
# Spring配置
|
# Spring配置
|
||||||
spring:
|
spring:
|
||||||
|
threads:
|
||||||
|
virtual:
|
||||||
|
enabled: true
|
||||||
mvc:
|
mvc:
|
||||||
pathmatch:
|
pathmatch:
|
||||||
matching-strategy: ant-path-matcher
|
matching-strategy: ant-path-matcher
|
||||||
|
|||||||
@@ -32,9 +32,7 @@ public class DictAspect {
|
|||||||
public Object aroundController(ProceedingJoinPoint joinPoint) throws Throwable {
|
public Object aroundController(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||||
Object result = joinPoint.proceed(); // 执行原方法
|
Object result = joinPoint.proceed(); // 执行原方法
|
||||||
|
|
||||||
if (result instanceof R) {
|
if (result instanceof R<?> response) {
|
||||||
// 如果返回值是 R<?>,提取其中的数据
|
|
||||||
R<?> response = (R<?>)result;
|
|
||||||
Object data = response.getData(); // 获取 R<?> 中的实际数据
|
Object data = response.getData(); // 获取 R<?> 中的实际数据
|
||||||
|
|
||||||
if (data instanceof Page) {
|
if (data instanceof Page) {
|
||||||
@@ -46,9 +44,7 @@ public class DictAspect {
|
|||||||
processDict(obj); // 处理每个 DTO 对象
|
processDict(obj); // 处理每个 DTO 对象
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (data instanceof List) {
|
} else if (data instanceof List<?> list) {
|
||||||
// 如果数据是 List 类型,处理列表数据
|
|
||||||
List<?> list = (List<?>)data;
|
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
for (Object obj : list) {
|
for (Object obj : list) {
|
||||||
processDict(obj); // 处理每个 DTO 对象
|
processDict(obj); // 处理每个 DTO 对象
|
||||||
@@ -88,8 +84,7 @@ public class DictAspect {
|
|||||||
continue; // 如果字段值为空,跳过
|
continue; // 如果字段值为空,跳过
|
||||||
}
|
}
|
||||||
// 如果字段是 List 类型,递归处理其中的每个元素
|
// 如果字段是 List 类型,递归处理其中的每个元素
|
||||||
if (fieldValue instanceof List) {
|
if (fieldValue instanceof List<?> list) {
|
||||||
List<?> list = (List<?>)fieldValue;
|
|
||||||
for (Object item : list) {
|
for (Object item : list) {
|
||||||
processDict(item); // 递归处理 List 中的每个元素
|
processDict(item); // 递归处理 List 中的每个元素
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ public class OperLogAspect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置操作结果
|
// 设置操作结果
|
||||||
if (result instanceof R) {
|
if (result instanceof R<?> r) {
|
||||||
R<?> r = (R<?>)result;
|
|
||||||
operLog.setJsonResult(JSON.toJSONString(r));
|
operLog.setJsonResult(JSON.toJSONString(r));
|
||||||
// 根据R的code判断操作状态
|
// 根据R的code判断操作状态
|
||||||
if (r.getCode() != 200) { // 假设200是成功状态码
|
if (r.getCode() != 200) { // 假设200是成功状态码
|
||||||
|
|||||||
Reference in New Issue
Block a user