mapbox / mapbox/mapbox-plugins-android
IndexOutOfBoundsException crash in updateSearchHistoryView
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 242
- 派生
- 116
- PR 合并指标
- 30 天内没有已合并 PR
描述
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)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 PlaceAutocompleteFragment.java 中的 updateSearchHistoryView 开始,尤其是第 218 行,并跟踪 issue 中报告的 historyCount 和 searchHistoryEntities 值。复现或测试 historyCount 为 3 而实体列表为空的状态,然后验证更新不再抛出 IndexOutOfBoundsException。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, java
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100