mapbox / mapbox/mapbox-plugins-android
IndexOutOfBoundsException crash in updateSearchHistoryView
- Dominant language
- Java
- Stars
- 242
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Description
The following code throws an exception:
PlaceAutocompleteFragment.java:218
for (int x = 0; x < historyCount; x++) {
searchHistoryView.getResultsList().add(searchHistoryEntities.get(x).getCarmenFeature());
}
Looks like historyCount = 3, but searchHistoryEntites.size() == 0
Not exactly sure why it got into this state internally, but it's causing the app to crash.
Stack trace:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.get(ArrayList.java:437)
at com.mapbox.mapboxsdk.plugins.places.autocomplete.ui.PlaceAutocompleteFragment.updateSearchHistoryView(PlaceAutocompleteFragment.java:218)
at com.mapbox.mapboxsdk.plugins.places.autocomplete.ui.PlaceAutocompleteFragment$2.onChanged(PlaceAutocompleteFragment.java:279)
at com.mapbox.mapboxsdk.plugins.places.autocomplete.ui.PlaceAutocompleteFragment$2.onChanged(PlaceAutocompleteFragment.java:276)
at androidx.lifecycle.LiveData.considerNotify(LiveData.java:113)
at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:131)
at androidx.lifecycle.LiveData.setValue(LiveData.java:289)
at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:33)
at androidx.lifecycle.LiveData$1.run(LiveData.java:91)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7319)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934)
Contributor guide
Research direction
Start in PlaceAutocompleteFragment.java at updateSearchHistoryView, especially line 218, and trace the historyCount and searchHistoryEntities values reported in the issue. Reproduce or test the state where historyCount is 3 while the entity list is empty, then verify the update no longer throws IndexOutOfBoundsException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100