fix: guard startSyncFolderOperation against a null folder (#4738) - #4986
Open
ibrahim-iqbal wants to merge 1 commit into
Open
ibrahim-iqbal wants to merge 1 commit into
ibrahim-iqbal wants to merge 1 commit into
Conversation
) `ReceiveExternalFilesViewModel.refreshFolderUseCase(folderToSync: OCFile)` is a Kotlin function with a non-null parameter. `ReceiveExternalFilesActivity` was passing the result of `getCurrentDir()` — which returns null whenever the storage manager cannot resolve the current folder — straight through without a null check, so the Kotlin platform-type check tripped the NPE that shows up in the Play console stack in issue owncloud#4738. Short-circuit `startSyncFolderOperation` when the folder is null and log the skip via Timber. All other callers already null-check the folder they pass in; the crash path was the `getCurrentDir()` handoff. Signed-off-by: ibrahim-iqbal <ibrahim-iqbal@users.noreply.github.com>
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.
Related Issues
App: closes #4738
ReceiveExternalFilesViewModel.refreshFolderUseCase(folderToSync: OCFile)is a Kotlin function with a non-null parameter.ReceiveExternalFilesActivity.startSyncFolderOperationforwarded whatever came in without a null check, so the two entry points that can hand back a null folder crashed with the Kotlin platform-type NPE reported in issue #4738:onSavedCertificate()→startSyncFolderOperation(getCurrentDir()), andFileActivity.getCurrentDir()returnsnullwhengetFile()is null, when the current file isn't a folder and the storage manager is missing, or when the storage manager can't resolve the parent path (FileActivity.java:455-466).refreshFolderUseCase (Unknown Source:6)is the Kotlin null check on the parameter.Changes
ReceiveExternalFilesActivity.startSyncFolderOperation: short-circuit and log via Timber whenfolderis null instead of forwarding to Kotlin.Kept every other caller unchanged —
onBackPressed(line 471),onItemClick(line 500), and the initial spaces-root call (line 259) already null-check the folder they pass in, so no other site needed the guard.Changelog file at
changelog/unreleased/4738(Bugfix:type).Release Notes in
ReleaseNotesViewModel.kt— crash-only, not a user-visible feature; happy to add one if you'd prefer.QA
./gradlew :owncloudApp:compileOriginalDebugJavaWithJavac→ BUILD SUCCESSFUL.startSyncFolderOperationhad to change; grep confirms four call sites and the three that aren'tgetCurrentDir()already guard the value.