对平(进度三字段进白名单 + 去掉那处新增吞异常): Java 全量 4313 例 0 红
上一笔 light 加 progress* 后我只跑了 6 个定向类,把两把钉白名单的尺子漏了—— 它们本来就是为「加字段必须显式承认」而设的,该红: - SimilarAsinTaskLightWhitelistTest(私有 LightVo 键集合,两处断言) - ResultFilePhaseContractTest(light 响应 JSON 键集快照) CatchSilenceRatchetTest 报「不重抛 559→560」也是我引入的:parseIntOrNull 用了 catch (NumberFormatException)。这处边界防护要留(Redis 里是客户端上报的裸字符串, 一次抛出就整页任务失去进度显示),但不必用 catch 实现——先按字符判掉非数字、再限 9 位 防 int 溢出,Integer.valueOf 就不可能抛。这样既守住棘轮也不动别人的 catch。 补一条用例把「负号/超长/非数字」三个分支钉住(否则改了没人验)。 教训写在这儿:改公共 DTO/VO 之后不许只跑定向,全量才是验收。
This commit is contained in:
+5
-2
@@ -21,7 +21,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
class SimilarAsinTaskLightWhitelistTest {
|
||||
|
||||
private static final Set<String> WHITELIST = new TreeSet<>(Set.of(
|
||||
"taskId", "status", "statusCode", "fileStatus", "fileError", "fileReady", "updatedAt"));
|
||||
"taskId", "status", "statusCode", "fileStatus", "fileError", "fileReady", "updatedAt",
|
||||
// progress*:客户端心跳上报的执行进度(2026-10-10 加入,三者同生同灭)
|
||||
"progressCurrent", "progressTotal", "progressLabel"));
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@@ -103,7 +105,8 @@ class SimilarAsinTaskLightWhitelistTest {
|
||||
@Test
|
||||
void whitelistExtraKeysRejected() throws Exception {
|
||||
// 回归门禁:白名单键集合与文档一致(新增键必须先更新本测试与 spec)
|
||||
assertEquals(List.of("fileError", "fileReady", "fileStatus", "status", "statusCode", "taskId", "updatedAt"),
|
||||
assertEquals(List.of("fileError", "fileReady", "fileStatus", "progressCurrent", "progressLabel",
|
||||
"progressTotal", "status", "statusCode", "taskId", "updatedAt"),
|
||||
new java.util.ArrayList<>(WHITELIST));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user