[AI Task] [Tizen.Network.Connection] Stop swallowing native exceptions in event accessors#7625
[AI Task] [Tizen.Network.Connection] Stop swallowing native exceptions in event accessors#7625JoonghyunCho wants to merge 2 commits into
Conversation
Each of the four internal events (ConnectionTypeChanged, IPAddressChanged, EthernetCableStateChanged, ProxyAddressChanged) wrapped its native-callback registration / deregistration in a broad catch (Exception) that logged and returned. For ConnectionTypeChanged and EthernetCableStateChanged the *Start methods actually throw via ConnectionErrorFactory.ThrowConnectionException, so registration could silently fail while the caller observed `+= handler` as having succeeded. Remove the eight try/catch blocks so native errors propagate to the caller. The Log.Error inside *Start / *Stop is preserved, and the exception type and message remain whatever ConnectionErrorFactory already produced. Fixes #7593
There was a problem hiding this comment.
Code Review
This pull request removes several try-catch blocks within event accessors in ConnectionInternalManager.cs to facilitate exception propagation during event registration and deregistration. The review feedback points out that the underlying helper methods for IPAddressChanged and ProxyAddressChanged still need to be updated to throw exceptions on native failures, as they currently only log errors, which prevents the intended propagation from occurring for those specific events.
| Log.Error(Globals.LogTag, $"Exception on adding IPAddressChanged\n{e.ToString()}"); | ||
| return; | ||
| } | ||
| IPAddressChangedStart(); |
There was a problem hiding this comment.
While removing the try-catch block here is correct to allow exception propagation, the underlying IPAddressChangedStart() method (lines 272-294) and its counterpart IPAddressChangedStop() (lines 296-304) do not currently call ConnectionErrorFactory.ThrowConnectionException(ret) on failure. To fully achieve the goal of propagating native failures to callers, these helper methods should be updated to throw exceptions when the native registration/deregistration fails, maintaining consistency with ConnectionTypeChangedStart and EthernetCableStateChangedStart.
There was a problem hiding this comment.
🤖 [AI Review]
Addressed in 6dd2831. IPAddressChangedStart and IPAddressChangedStop now call ConnectionErrorFactory.ThrowConnectionException(ret) on failure.
| Log.Error(Globals.LogTag, $"Exception on adding ProxyAddressChanged\n{e.ToString()}"); | ||
| return; | ||
| } | ||
| ProxyAddressChangedStart(); |
There was a problem hiding this comment.
Similar to the IPAddressChanged event, the ProxyAddressChangedStart() (lines 332-354) and ProxyAddressChangedStop() (lines 356-364) methods currently only log errors without throwing exceptions. Removing the try-catch block in this accessor won't result in exception propagation for native failures until these helper methods are updated to call ConnectionErrorFactory.ThrowConnectionException(ret).
There was a problem hiding this comment.
🤖 [AI Review]
Addressed in 6dd2831. ProxyAddressChangedStart and ProxyAddressChangedStop now call ConnectionErrorFactory.ThrowConnectionException(ret) on failure.
|
🤖 [AI Review] Reviewed — no findings. Scope checked:
No 🔴 critical issues, no 🟡 suggestions to flag. Automated review — final merge decision rests with human reviewers. |
Throw ConnectionException when registering or unregistering the IPAddressChanged and ProxyAddressChanged native callbacks fails, so the event accessors actually surface native failures to callers in line with the ConnectionTypeChanged and EthernetCableStateChanged helpers. Applied-Human-Comments: 3214748998,3214749000
|
🤖 [AI Review] |
Summary
Removes the broad
catch (Exception)swallow blocks in the four internal event accessors ofConnectionInternalManager, so that native registration / deregistration failures propagate to callers instead of producing a silent log-only failure.Changes
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.csConnectionTypeChanged(add / remove): drop try/catch wrappingConnectionTypeChangedStart()/ConnectionTypeChangedStop().IPAddressChanged(add / remove): drop try/catch wrappingIPAddressChangedStart()/IPAddressChangedStop().EthernetCableStateChanged(add / remove): drop try/catch wrappingEthernetCableStateChangedStart()/EthernetCableStateChangedStop().ProxyAddressChanged(add / remove): drop try/catch wrappingProxyAddressChangedStart()/ProxyAddressChangedStop().Total: 8 try/catch blocks removed (~75% reduction in lines for those accessors).
Log.Erroralready exists inside the*Start/*Stophelpers themselves, so diagnostics are preserved. The exception type and message thrown byConnectionErrorFactory.ThrowConnectionExceptionare unchanged.Mode
Refactoring (Option A from the issue: propagate exceptions). No public API signatures change. Behaviorally,
ConnectionTypeChangedandEthernetCableStateChangedpreviously swallowed native registration failures (silent failure path); the change surfaces those failures to callers — this is the intended bug-visibility fix.Verification
dotnet build src/Tizen.Network.Connection/Tizen.Network.Connection.csproj— 0 errors, 0 warnings)API compatibility note
ConnectionInternalManageris aninternal sealedsingleton, but its events are surfaced byTizen.Network.Connection.Connectionto user code. Callers of+= handleron the corresponding public events may now observe exceptions (e.g.,NotSupportedException,InvalidOperationException) where they previously saw a silent log + no registration. This is a behavioral change and intentional — see the issue for rationale. Migration / release-note coverage recommended.Fixes #7593