Skip to content

Catch FileNotFoundException in AssetFileSystem.existsInternal#1815

Open
dellisd wants to merge 1 commit into
square:masterfrom
dellisd:derekellis.2026-06-16.asset-catch
Open

Catch FileNotFoundException in AssetFileSystem.existsInternal#1815
dellisd wants to merge 1 commit into
square:masterfrom
dellisd:derekellis.2026-06-16.asset-catch

Conversation

@dellisd

@dellisd dellisd commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Under certain circumstances, the native asset manager implementation can throw a FileNotFoundException if the asset directory cannot be opened for listing (see https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/core/jni/android_util_AssetManager.cpp#475)

This can, for example, cause AssetFileSystem.exists() to throw instead of returning false which is (arguably?) different from the behaviour of other FileSystem implementations.

val children = try {
assets.list(parent.toAssetRelativePathString()).orEmpty()
} catch (_: FileNotFoundException) {
return false

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return false
emptyList()

Doesn't really matter, but same behavior through a single return.

Under certain circumstances, the native asset manager implementation can throw a `FileNotFoundException` if the asset directory cannot be opened for listing (see https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/core/jni/android_util_AssetManager.cpp#475)

This can, for example, cause `AssetFileSystem.exists()` to throw instead of returning `false` which is (arguably?) different from the behaviour of other `FileSystem` implementations.
@dellisd dellisd force-pushed the derekellis.2026-06-16.asset-catch branch from 26aca81 to c2dacab Compare June 17, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants