橘子899 2022-03-16 00:14 采纳率: 78.6%
浏览 68
已结题

求这个问题解决方法 java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at cn.com.lundong.feishu.core.contact.service.impl.FeishuUserServiceImpl.getUserByOpenId(FeishuUserServiceImpl.java:354)
at cn.com.lundong.feishu.core.contact.service.impl.FeishuUserServiceImpl$$FastClassBySpringCGLIB$$a5091579.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)


        LambdaQueryWrapper<FeishuUserPo> queryWrapper = Wrappers.<FeishuUserPo>lambdaQuery()
                .eq(FeishuUserPo::getTenantKey, tenantKey)
                .eq(FeishuUserPo::getAppId, appId)
                .eq(FeishuUserPo::getOpenId, openId)
                .eq(FeishuUserPo::getAuthorize, 1)
                .orderByAsc(FeishuUserPo::getCreateTime);
      

        List<FeishuUserPo> feishuUserPos = this.baseMapper.selectList(queryWrapper);

        if (feishuUserPos !=null && feishuUserPos.size() > 0){
            return  feishuUserPos.get(0);
        }
             return null;
    }

  • 写回答

2条回答 默认 最新

  • 大鹏cool Java领域优质创作者 2022-03-16 07:39
    关注

    检查 FeishuUserServiceImpl.java 文件 354 行代码,List 为空时获取了索引为 0 的元素。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 3月30日
  • 已采纳回答 3月22日
  • 创建了问题 3月16日

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程