简体   繁体   中英

java.util.ArrayList throwing IndexOutOfBounds exception

I came across the following trace today:

java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
    at java.util.ArrayList.rangeCheck(ArrayList.java:635)
    at java.util.ArrayList.get(ArrayList.java:411)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1720)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
    at [.. somewhere in my code]

During that time the system was very busy and I guess also strained for memory and I was also experiencing some heap exhaustion errors ( java.lang.OutOfMemoryError: Java heap space ). Since the above trace came out of the guts of system / PostgreSQL / Apache libraries is it likely that a system very low on memory could trigger it?

It doesn't look like an issue in my code or the trace wouldn't have been so deep, right?

ArrayLists use zero-based indexes, the index 2 is invalid in a list of length 2 (the information given in your trace). It is probably an issue in your code that was passed through the query engine until it triggered the exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM