Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

A crash in GeoJsonSource::setGeoJson(FeatureCollection features) #14897

Closed
maxtracking opened this issue Jun 11, 2019 · 2 comments · Fixed by #14898
Closed

A crash in GeoJsonSource::setGeoJson(FeatureCollection features) #14897

maxtracking opened this issue Jun 11, 2019 · 2 comments · Fixed by #14898
Labels
Android Mapbox Maps SDK for Android

Comments

@maxtracking
Copy link

maxtracking commented Jun 11, 2019

GeoJsonSource::setGeoJson(FeatureCollection features) seems to be changed in 8.1.0-alpha.2 compared to eg 8.0.0. The parameter is not annotated (neither Nullable nor NotNull) so it results in a crash when one passed null in that method.

Steps to reproduce

  1. Create GeoJsonSource instance
  2. Execute the following sample code:
    val featureCollection: FeatureCollection? = null // I put null explicitly here but it can be a result of some logic
    geoJsonSource.setGeoJson(featureCollection)
    
  3. Observe NPE

Expected behavior

Either annotate the method so there will be some warning or Android Studio indication OR check for null in the implementation

Actual behavior

A crash like

E/SomeActivity$onStart: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.mapbox.geojson.FeatureCollection.features()' on a null object reference
        at com.mapbox.mapboxsdk.style.sources.GeoJsonSource.setGeoJson(GeoJsonSource.java:296)

Configuration

Android versions: 8.0
Device models: Custom but doesn't matter
Mapbox SDK versions: 8.1.0-alpha.2

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Jun 11, 2019
@tobrun
Copy link
Member

tobrun commented Jun 11, 2019

Thanks for the report and testing out our pre releases. This behavior originates from #14804 and should be restored as before with #14898.

@maxtracking
Copy link
Author

Thanks @tobrun!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants