fix(core): DBWrapper 快速失败并容错退化查询结果#533
Merged
Merged
Conversation
…ults - Init now throws instead of swallowing factory errors, so an empty database list can no longer make every operation silently no-op while the benchmark reports success. - deviceSummary() returns null on an empty result and reuses the agreed summary, removing the NPE when the last loop iteration left it null. - aggRangeValueQuery records each status inside the loop. - doPointComparison() skips (returns -1) when fewer than two databases are present instead of indexing out of bounds. - Add DBWrapper.forTest seam, FakeDB(DBConfig) ctor, and public Measurement counters so DBWrapperTest / FakeDBEndToEndTest can inject fakes and assert counters (via BenchmarkTestBase).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
DBWrapper在若干退化场景下行为不健壮:DBFactory异常,使databases为空,之后所有操作静默 no-op,基准测试却"成功",实际什么都没读写。deviceSummary()在最后一次循环可能让结果引用保持 null,随后 NPE。aggRangeValueQuery的handleQueryOperation位置不当。doPointComparison()在数据库少于两个(非双写)时按下标取值越界。改动
IllegalStateException,快速失败。deviceSummary():结果为空时返回 null;复用已确认的非空 summary,消除 NPE。aggRangeValueQuery:在循环内逐条记录 status。doPointComparison():少于两个数据库时跳过(返回 -1),不再越界。DBWrapper.forTest、FakeDB(DBConfig)构造器、Measurement计数器 getter 改 public,便于注入 fake 并断言计数。验证
新增
DBWrapperTest、FakeDBEndToEndTest(经BenchmarkTestBase)共 6 个用例通过;spotless 通过。说明
基于
master的独立分支。Measurement.java仅含 getter 可见性改动,与 measurement 分支不重叠。