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