mapbox / mapbox/mapbox-plugins-android

IndexOutOfBoundsException crash in updateSearchHistoryView

Offen
#1,024 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

places-plugin
Vorherrschende Sprache
Java
Sterne
242
Forks
116
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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)

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie in PlaceAutocompleteFragment.java bei updateSearchHistoryView, insbesondere in Zeile 218, und verfolgen Sie die im Issue gemeldeten Werte von historyCount und searchHistoryEntities. Reproduzieren oder testen Sie den Zustand, in dem historyCount 3 beträgt, während die Entitätsliste leer ist, und überprüfen Sie anschließend, dass das Update nicht mehr IndexOutOfBoundsException auslöst.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, java
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.