java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

Kuali JIRA | Miki Harmath | 4 years ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafael . Or join the community to write better ones.
  1. 0

    To replicate: 1. create a blank calendar: 2030 acal (08/20/2030 - 08/19/2031) 2. add in a Fall term (08/20/2030 - 12/13/2030); add in an instructional key date: first day of classes: 08/20/2030; save the acal. 3. edit the acal, add in a Winter term (01/03/2031 - 01/31/2031). 4. update the "first day of classes" key date of Fall term to 08/21/2030 5. save the acal. Stacktrace: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:604) at java.util.ArrayList.get(ArrayList.java:382) at org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.saveDirtyFieldChanges(AcademicCalendarController.java:1091) at org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.saveAcademicCalendarDirtyFields(AcademicCalendarController.java:979) at org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.save(AcademicCalendarController.java:354) at org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController$$FastClassByCGLIB$$ed610153.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631) at org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController$$EnhancerByCGLIB$$4670fbc2.save(<generated>) at sun.reflect.GeneratedMethodAccessor1874.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) ============================================================================================================================ Cause of the issue: It happens when you update some key dates of existing terms while you create a new term and then save the acal. In this case, viewHelperService.validateAcademicCalendar will sort the terms list based on the start dates before the dirty fields are processed (it does this to make sure the warning/error messages can be point to the correct terms after the terms are sorted later on). However, the dirty fields processing is based on the term order before the viewHelperService.validateAcademicCalendar sorts the terms. And therefore, the dirty fields processing method can’t locate the right fields in correct term to process. E.g. We currently have one term Fall Term 2012 and we are creating a new term Winter Term 2013. We update one key date of Fall Term 2012 and create one key date for Winter Term 2013. Before viewHelperService.validateAcademicCalendar sorts the term list, we have the following in our term list. Winter Term 2013 (index:0) Fall Term 2012 (index: 1) After the term list is sorted, we have the following because Fall Term 2012 has an earlier start date than Winter Term 2013. Fall Term 2012 (index:0) Winter Term 2013 (index: 1) However, our dirty fields processing method works based on the order of the list before the sorting happens. It thinks that we updated the keydate of the Winter Term 2013 in the term list, which results in the issue.

    Kuali JIRA | 4 years ago | Miki Harmath
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  2. 0

    To replicate: 1. create a blank calendar: 2030 acal (08/20/2030 - 08/19/2031) 2. add in a Fall term (08/20/2030 - 12/13/2030); add in an instructional key date: first day of classes: 08/20/2030; save the acal. 3. edit the acal, add in a Winter term (01/03/2031 - 01/31/2031). 4. update the "first day of classes" key date of Fall term to 08/21/2030 5. save the acal. Stacktrace: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:604) at java.util.ArrayList.get(ArrayList.java:382) at org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.saveDirtyFieldChanges(AcademicCalendarController.java:1091) at org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.saveAcademicCalendarDirtyFields(AcademicCalendarController.java:979) at org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.save(AcademicCalendarController.java:354) at org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController$$FastClassByCGLIB$$ed610153.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631) at org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController$$EnhancerByCGLIB$$4670fbc2.save(<generated>) at sun.reflect.GeneratedMethodAccessor1874.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) ============================================================================================================================ Cause of the issue: It happens when you update some key dates of existing terms while you create a new term and then save the acal. In this case, viewHelperService.validateAcademicCalendar will sort the terms list based on the start dates before the dirty fields are processed (it does this to make sure the warning/error messages can be point to the correct terms after the terms are sorted later on). However, the dirty fields processing is based on the term order before the viewHelperService.validateAcademicCalendar sorts the terms. And therefore, the dirty fields processing method can’t locate the right fields in correct term to process. E.g. We currently have one term Fall Term 2012 and we are creating a new term Winter Term 2013. We update one key date of Fall Term 2012 and create one key date for Winter Term 2013. Before viewHelperService.validateAcademicCalendar sorts the term list, we have the following in our term list. Winter Term 2013 (index:0) Fall Term 2012 (index: 1) After the term list is sorted, we have the following because Fall Term 2012 has an earlier start date than Winter Term 2013. Fall Term 2012 (index:0) Winter Term 2013 (index: 1) However, our dirty fields processing method works based on the order of the list before the sorting happens. It thinks that we updated the keydate of the Winter Term 2013 in the term list, which results in the issue.

    Kuali JIRA | 4 years ago | Miki Harmath
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  3. 0
    samebug tip
    Thrown to indicate that an index of some sort (such as to an array, to a string, or to a vector) is out of range. Applications can subclass this class to indicate similar exceptions.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Build failure with the latest git code

    GitHub | 4 years ago | sanjana-bhat
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  6. 0

    Mule EventCorrelator IndexOutOfBoundsException

    Stack Overflow | 3 years ago | Tashani Kathriarachchi
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IndexOutOfBoundsException

    Index: 0, Size: 0

    at java.util.ArrayList.rangeCheck()
  2. Java RT
    ArrayList.get
    1. java.util.ArrayList.rangeCheck(ArrayList.java:604)
    2. java.util.ArrayList.get(ArrayList.java:382)
    2 frames
  3. org.kuali.student
    AcademicCalendarController$$FastClassByCGLIB$$ed610153.invoke
    1. org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.saveDirtyFieldChanges(AcademicCalendarController.java:1091)
    2. org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.saveAcademicCalendarDirtyFields(AcademicCalendarController.java:979)
    3. org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.save(AcademicCalendarController.java:354)
    4. org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController$$FastClassByCGLIB$$ed610153.invoke(<generated>)
    4 frames
  4. Spring Core
    MethodProxy.invoke
    1. org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    1 frame
  5. Spring AOP
    CglibAopProxy$DynamicAdvisedInterceptor.intercept
    1. org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
    2. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    3. org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
    4. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    5. org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
    5 frames
  6. org.kuali.student
    AcademicCalendarController$$EnhancerByCGLIB$$4670fbc2.save
    1. org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController$$EnhancerByCGLIB$$4670fbc2.save(<generated>)
    1 frame
  7. Java RT
    Method.invoke
    1. sun.reflect.GeneratedMethodAccessor1874.invoke(Unknown Source)
    2. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    3. java.lang.reflect.Method.invoke(Method.java:601)
    3 frames