ArrayList.add()
should never throw an ArrayIndexOutOfBoundsException
if used "properly" so it seems that you're using your ArrayList
in a way which it does not support.
It's hard to tell from just the code you've posted but my guess is that you're accessing your ArrayList
from multiple threads.
ArrayList
isn't synchronised and so isn't thread safe. If this is the problem you can fix it by wrapping your List
using Collections.synchronizedList().
Changing your code to the following should resolve the problem:
private void populateInboxResultHolder(List inboxErrors){
List inboxList = Collections.synchronizedList(new ArrayList());
try{
inboxHolder = new InboxResultHolder();
//Lots of Code
inboxList.add(inboxHolder);
}catch(Exception e){
e.printStackTrace();
}
}