fix(ble): prevent app crash on sendResponse to disconnected central (COLUMBA-6Q) - #1088
Open
sentry[bot] wants to merge 1 commit into
Open
fix(ble): prevent app crash on sendResponse to disconnected central (COLUMBA-6Q)#1088sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
Contributor
Greptile SummaryThe PR prevents a framework-originated exception from crashing the Reticulum host process when a BLE central disconnects during GATT request processing.
Confidence Score: 5/5The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issues identified. The helper preserves every existing GATT response argument and call condition while preventing the documented disconnected-central framework exception from escaping into the host process. Important Files Changed
Reviews (1): Last reviewed commit: "fix(ble): prevent app crash on sendRespo..." | Re-trigger Greptile |
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.
This PR addresses a
NullPointerExceptionthat occurs when theBleGattServerattempts to send a GATT response (gattServer?.sendResponse(...)) to a BLE central device that has disconnected during the asynchronous processing of a GATT request (e.g., read/write/descriptor request).The root cause is an internal
RuntimeExceptionthrown by the Android Bluetooth system service when it cannot resolve the connection ID for a disconnected device. This exception is parceled back to the app process, leading to a crash because thesendResponsecalls were not wrapped in atry/catchblock that handlesRuntimeException.Previous attempts to fix this issue (PR #700, PR #843) misdiagnosed the problem as a Kotlin null-unboxing issue related to the
offsetparameter, which did not resolve the underlying framework exception.This fix introduces a
safeSendResponsehelper function that wraps thegattServer?.sendResponse(...)call in atry/catch(RuntimeException). This prevents the app from crashing by gracefully handling the exception when a central disconnects, logging a warning instead. All existinggattServer?.sendResponse(...)calls inBleGattServerhave been updated to use this new safe helper.Fixes COLUMBA-6Q