From 807ea1118722f39ecc0192b9433a3685a872e7f7 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Fri, 22 May 2026 09:27:08 -0400 Subject: [PATCH] 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) --- code-reviews/Driver.FOCAS/findings.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code-reviews/Driver.FOCAS/findings.md b/code-reviews/Driver.FOCAS/findings.md index 94fd87e..f828dfe 100644 --- a/code-reviews/Driver.FOCAS/findings.md +++ b/code-reviews/Driver.FOCAS/findings.md @@ -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