qunarcorp / bistoury

Bistoury是去哪儿网的java应用生产问题诊断工具,提供了一站式的问题诊断方案
GNU General Public License v3.0
4.04k stars 830 forks source link

首页选择应用时,当应用数量少于20个,会报数据越界错误 #98

Open ljzforever opened 4 years ago

ljzforever commented 4 years ago

AdminAppServiceImpl类第54行

if (Strings.isNullOrEmpty(key)) {
    return adminApps.asList().subList(0, size);
}

subList方法会调用Preconditions.checkPositionIndexes方法,当adminApps数量少于size时,会报数据越界错误

我的修正方法如下

if (Strings.isNullOrEmpty(key)) {
    ImmutableList<String> adminAppLists = adminApps.asList();
    if (adminAppLists.size() > size) {
        return adminAppLists.subList(0, size);
    }
    return adminAppLists;
}
xleiy commented 4 years ago

已修复 https://github.com/qunarcorp/bistoury/commit/271b0594039bf1bec888e976920490ad96f27bc3