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

求这个问题解决方法 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 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了