review(Driver.AbLegacy.Cli): add FlushLogging() to command finally blocks
Re-review at 7286d320. -008 (Low): all four commands now FlushLogging() in finally (parity
with AbCip.Cli; subscribe could drop shutdown log lines) + IL-inspection test.
This commit is contained in:
@@ -4,16 +4,39 @@
|
||||
|---|---|
|
||||
| Module | `src/Drivers/Cli/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Cli` |
|
||||
| Reviewer | Claude Code |
|
||||
| Review date | 2026-05-22 |
|
||||
| Commit reviewed | `76d35d1` |
|
||||
| Review date | 2026-06-19 |
|
||||
| Commit reviewed | `111d6983` |
|
||||
| Status | Reviewed |
|
||||
| Open findings | 0 |
|
||||
|
||||
## Re-review 2026-06-19 (commit 111d6983)
|
||||
|
||||
Re-review at HEAD `111d6983`. No changes in this module since the last review commit `7286d320`. Sibling module Driver.Cli.Common received a fix (`1180b017`) but the `FlushLogging` omission was not back-ported to AbLegacy. Cross-module comparison against the AbCip CLI (which received Driver.AbCip.Cli-005 fix) revealed the single new finding below.
|
||||
|
||||
#### Changes since prior review
|
||||
|
||||
No source files in this module changed between `7286d320` and `111d6983`. The finding was surfaced by comparing the AbLegacy CLI commands against the AbCip CLI siblings, which had `FlushLogging()` calls added in a prior review cycle.
|
||||
|
||||
## Checklist coverage
|
||||
|
||||
A comprehensive review completes every category, recording "No issues found" where
|
||||
a category produced nothing rather than leaving it blank.
|
||||
|
||||
| # | Category | Result |
|
||||
|---|---|---|
|
||||
| 1 | Correctness & logic bugs | No issues found |
|
||||
| 2 | OtOpcUa conventions | No issues found |
|
||||
| 3 | Concurrency & thread safety | No issues found |
|
||||
| 4 | Error handling & resilience | Driver.AbLegacy.Cli-008 |
|
||||
| 5 | Security | No issues found |
|
||||
| 6 | Performance & resource management | Driver.AbLegacy.Cli-008 |
|
||||
| 7 | Design-document adherence | No issues found |
|
||||
| 8 | Code organization & conventions | No issues found |
|
||||
| 9 | Testing coverage | No issues found |
|
||||
| 10 | Documentation & comments | No issues found |
|
||||
|
||||
Prior review checklist (commit `76d35d1`, 2026-05-22):
|
||||
|
||||
| # | Category | Result |
|
||||
|---|---|---|
|
||||
| 1 | Correctness & logic bugs | Driver.AbLegacy.Cli-001, Driver.AbLegacy.Cli-002 |
|
||||
@@ -241,3 +264,39 @@ analyzer. The overflow path for `ParseValue` is already covered by
|
||||
`WriteCommandParseValueTests.ParseValue_out_of_range_throws_CommandException`
|
||||
(theory with `short.Parse` + `AnalogInt` overflow inputs), added when finding
|
||||
Driver.AbLegacy.Cli-001 was resolved.
|
||||
|
||||
---
|
||||
|
||||
## Findings (re-review 2026-06-19)
|
||||
|
||||
### Driver.AbLegacy.Cli-008
|
||||
|
||||
| Field | Value |
|
||||
|---|---|
|
||||
| Severity | Low |
|
||||
| Category | Error handling & resilience / Performance & resource management |
|
||||
| Location | `Commands/ProbeCommand.cs:58-61`, `Commands/ReadCommand.cs:52-55`, `Commands/WriteCommand.cs:62-65`, `Commands/SubscribeCommand.cs:88-96` |
|
||||
| Status | Resolved |
|
||||
|
||||
**Description:** All four commands call `ConfigureLogging()` at the top of
|
||||
`ExecuteAsync` but none call `FlushLogging()` (`Log.CloseAndFlush()`) in their
|
||||
`finally` block. The `DriverCommandBase` XML doc explicitly states "Call
|
||||
`FlushLogging` in a `finally` block to ensure buffered output is flushed before
|
||||
the process exits." For the one-shot commands (`probe`, `read`, `write`) the
|
||||
console sink is flushed on process exit anyway, so the practical impact is nil
|
||||
there. For `subscribe` — a long-running command terminated by Ctrl+C — buffered
|
||||
Serilog lines emitted during `ShutdownAsync` can be silently dropped on abrupt
|
||||
exit. The sibling AbCip CLI already received this fix (Driver.AbCip.Cli-005,
|
||||
resolved 2026-06-19); AbLegacy was not updated in the same pass.
|
||||
|
||||
**Recommendation:** Add `FlushLogging();` at the end of each command's `finally`
|
||||
block, after `ShutdownAsync`, mirroring the AbCip CLI fix.
|
||||
|
||||
**Resolution:** Resolved 2026-06-19 — added `FlushLogging()` in the `finally`
|
||||
block of all four commands (`ProbeCommand`, `ReadCommand`, `WriteCommand`,
|
||||
`SubscribeCommand`) with an explanatory comment referencing this finding ID.
|
||||
Added IL-inspection theory test
|
||||
`CommandMetadataTests.ExecuteAsync_calls_FlushLogging_in_state_machine` (4
|
||||
theory cases) that walks each command's compiler-generated async state-machine
|
||||
`MoveNext` IL to verify the `DriverCommandBase.FlushLogging` method token is
|
||||
present; test was red before the fix, green after. All 36 tests pass.
|
||||
|
||||
Reference in New Issue
Block a user