Skip to content

fix(android): guard null logger during schema downgrade - #1992

Open
liwenju0 wants to merge 1 commit into
Nozbe:masterfrom
liwenju0:codex/fix-android-downgrade-null-logger
Open

liwenju0 wants to merge 1 commit into
Nozbe:masterfrom
liwenju0:codex/fix-android-downgrade-null-logger

Conversation

@liwenju0

Copy link
Copy Markdown

Fixes #1991.

Opening a database whose version is newer than the app schema currently rejects with a NullPointerException on the legacy Android SQLite bridge in Release builds. The constructor sets log to null when debug logging is disabled, but isCompatible() calls log.info() unconditionally in its newer-database branch.

Guard that diagnostic call with if (log != null), matching the existing guard in unsafeResetDatabase(), so the method reaches its existing NeedsSetup result. Add a changelog entry and four Android instrumentation regression tests:

  • Newer database with a null logger.
  • Newer database with logging enabled.
  • Matching versions with a null logger.
  • Older database with a null logger.

The native test app uses testBuildType "debug". The regression tests set the driver's logger to null through reflection to reproduce the Release state, and invoke the private compatibility check without widening the production API. Each test uses a real, isolated SQLite database. The null-logger downgrade test also checks that classification alone leaves the existing row intact.

Validation

Ran the exact new instrumentation test class on an Android API 34 arm64 emulator using an isolated Gradle harness that compiles the upstream Java driver/SQLite implementation and the committed test file. The harness omits the React Native application/JS bundle:

  • Before: 4 tests run, 1 failure: newerDatabaseWithNullLoggerNeedsSetup throws NullPointerException at Logger.info().
  • After: OK (4 tests).
  • A separate JVM probe compiled from the upstream driver source also passes all five compatibility cases (including an empty database) after failing the null-logger downgrade case before the fix.
  • git diff --check passes.

The complete React Native bridge integration suite and yarn ci:check were not run locally. The new tests live in the existing native/androidTest instrumentation source set for the Android CI job.

Downgrade behavior

The existing NeedsSetup policy is unchanged: opening a newer database proceeds to destructive schema setup. This patch fixes the unintended logging exception; it does not implement a data-preserving downgrade or make schema-changing OTA rollback safe. Applications must still protect unsynced local data.

The C++ JSI and iOS implementations are unchanged. Related setup/reset-error work in #1981 and #1983 does not modify this compatibility branch.

This branch has not been deployed

No deployments
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.

[Android] Release SQLite adapter crashes when database schema is newer than app schema

1 participant