Skip to content

fix: prevent NullPointerException in RNMBXAtmosphere.addStyles()#4171

Open
zamausa wants to merge 1 commit intornmapbox:mainfrom
zamausa:fix/atmosphere-null-crash
Open

fix: prevent NullPointerException in RNMBXAtmosphere.addStyles()#4171
zamausa wants to merge 1 commit intornmapbox:mainfrom
zamausa:fix/atmosphere-null-crash

Conversation

@zamausa
Copy link
Contributor

@zamausa zamausa commented Mar 9, 2026

Description

Fix crash in RNMBXAtmosphere.addStyles() caused by non-null assertions (!!) on mReactStyle and mMap. When addStyles() is called before these properties are initialized (e.g. via setReactStyle() before addToMap()), the !! operator throws a NullPointerException.

Replaced with safe early-return null checks using Kotlin ?: patterns, consistent with how mAtmosphere is already guarded.

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

Component to reproduce the issue you're fixing

Any usage of the <Atmosphere> component can trigger the crash when setReactStyle is called before the component is added to the map.

Replace non-null assertions (!!) on mReactStyle and mMap with safe early-return null checks to prevent crashes when addStyles() is called before these properties are initialized.
@zamausa zamausa requested a deployment to CI with Mapbox Tokens March 9, 2026 22:59 — with GitHub Actions Waiting
@zamausa zamausa requested a deployment to CI with Mapbox Tokens March 9, 2026 22:59 — with GitHub Actions Waiting
@zamausa zamausa requested a deployment to CI with Mapbox Tokens March 9, 2026 22:59 — with GitHub Actions Waiting
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.

1 participant