提交审批 dogfooding 修复:桥接清洗 joda 时间变量避免 Flowable 序列化崩
P4 写路径巡检(HR_HOLIDAYAPPLY_SUBMIT)揪到:业务变量含 org.joda.time.DateTime(BEGINTIME), FlowableClient POST 时 Jackson 无 joda 模块→InvalidDefinitionException 起审批崩+泄露类名。 桥接 jsonSafeValue 反射检测 joda 时间类→epoch 毫秒(不引 joda 编译依赖)。集成重跑 status 0。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -83,6 +83,11 @@ public class ProcessCoreServiceBridge {
|
||||
vars.put(ProcessCoreService.INITIATORDEPARTID, currentDepart);
|
||||
vars.put(INITIATORTIME, new java.util.Date());
|
||||
|
||||
// dogfooding(HR_HOLIDAYAPPLY_SUBMIT)实测:保真层 POJO 的日期列是 org.joda.time.DateTime,
|
||||
// FlowableClient 经 RestClient 序列化 POST 时 Jackson 默认无 joda 模块 → InvalidDefinitionException
|
||||
// 起审批崩(且 msg 泄露类名)。此处把变量里的 joda 时间类型清洗为 JSON 安全形态。
|
||||
vars.replaceAll((k, v) -> jsonSafeValue(v));
|
||||
|
||||
Map<String, Object> startRequest = new LinkedHashMap<>();
|
||||
startRequest.put("processDefinitionKey", processName);
|
||||
startRequest.put("businessKey", businessKey);
|
||||
@@ -101,4 +106,21 @@ public class ProcessCoreServiceBridge {
|
||||
processName, businessKey, tableName, inst != null && inst.ended, target);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把流程变量值清洗成 JSON 可序列化形态:joda 时间类型(Jackson 默认不支持)→ epoch 毫秒
|
||||
* (Instant 族有 getMillis)或 ISO 字符串(LocalDate 等无 getMillis)。其它类型原样保留。
|
||||
*
|
||||
* <p>用反射按类名检测,避免对 joda-time 形成编译期硬依赖(其仅为保真层传递依赖)。
|
||||
*/
|
||||
private static Object jsonSafeValue(Object v) {
|
||||
if (v == null || !v.getClass().getName().startsWith("org.joda.time.")) {
|
||||
return v;
|
||||
}
|
||||
try {
|
||||
return (Long) v.getClass().getMethod("getMillis").invoke(v);
|
||||
} catch (ReflectiveOperationException | ClassCastException e) {
|
||||
return v.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user