fix(driver-focas): resolve Medium code-review finding (Driver.FOCAS-006)
EnsureConnectedAsync now disposes and nulls any existing non-connected client before creating a fresh one via _clientFactory.Create(). Previously the method reused a cached client via ConnectAsync, but a client disposed by a HandleRecycle race or prior teardown would hit FocasWireClient.ThrowIfDisposed on every subsequent call, leaving the device permanently wedged with BadCommunicationError and no recovery path until ReinitializeAsync. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
| Review date | 2026-05-22 |
|
||||
| Commit reviewed | `76d35d1` |
|
||||
| Status | Reviewed |
|
||||
| Open findings | 7 |
|
||||
| Open findings | 6 |
|
||||
|
||||
## Checklist coverage
|
||||
|
||||
@@ -172,7 +172,7 @@ uses `ProbeLock`; apply the same discipline to driver health.
|
||||
| Severity | Medium |
|
||||
| Category | Error handling & resilience |
|
||||
| Location | `FocasDriver.cs:859-874`, `WireFocasClient.cs:22-31` |
|
||||
| Status | Open |
|
||||
| Status | Resolved |
|
||||
|
||||
**Description:** `EnsureConnectedAsync` reuses the cached `IFocasClient` instance across
|
||||
a transient disconnect: it only checks `device.Client is { IsConnected: true }` and
|
||||
@@ -191,7 +191,7 @@ as unrecoverable and recreate it from `_clientFactory`. Simplest: in
|
||||
null it before creating a fresh instance, rather than retrying `ConnectAsync` on the
|
||||
stale object.
|
||||
|
||||
**Resolution:** _(open)_
|
||||
**Resolution:** Resolved 2026-05-22 — `EnsureConnectedAsync` now unconditionally disposes and nulls any existing non-connected client before calling `_clientFactory.Create()`, preventing `ObjectDisposedException` loops on a stale `WireFocasClient` after a `HandleRecycle` race or prior teardown.
|
||||
|
||||
### Driver.FOCAS-007
|
||||
|
||||
|
||||
Reference in New Issue
Block a user