Details
-
Bug
-
Resolution: Fixed
-
Major
-
None
-
None
-
Operating System: Windows
Platform: PC
-
148
Description
We sometimes receive strange exceptions in our webapp:
[21/Apr/2008:21:00:58] warning ( 1596): CORE3283: stderr: Exception in thread "Thread-6" java.lang.ArrayIndexOutOfBoundsException
[21/Apr/2008:21:00:58] warning ( 1596): CORE3283: stderr: at java.lang.System.arraycopy(Native Method)
[21/Apr/2008:21:00:58] warning ( 1596): CORE3283: stderr: at java.util.ArrayList.ensureCapacity(ArrayList.java:170)
[21/Apr/2008:21:00:58] warning ( 1596): CORE3283: stderr: at java.util.ArrayList.add(ArrayList.java:351)
[21/Apr/2008:21:00:58] warning ( 1596): CORE3283: stderr: at ch.qos.logback.core.BasicStatusManager.add(BasicStatusManager.java:38)
[21/Apr/2008:21:00:58] warning ( 1596): CORE3283: stderr: at ch.qos.logback.core.spi.ContextAwareBase.addStatus(ContextAwareBase.java:59)
[21/Apr/2008:21:00:58] warning ( 1596): CORE3283: stderr: at ch.qos.logback.core.spi.ContextAwareBase.addInfo(ContextAwareBase.java:64)
I just tried to analyze the problem and found out that ch.qos.logback.classic.jmx.Configurator is simply using the iterator of the status manager without synchronizing, as it's documented in BasicStatusManager.
So instead of
public List<String> getStatuses() {
List<String> list = new ArrayList<String>();
Iterator<Status> it = context.getStatusManager().iterator();
while(it.hasNext())
return list;
}
it should probably be
public List<String> getStatuses() {
List<String> list = new ArrayList<String>();
StatusManager sm = context.getStatusManager();
Iterator<Status> it = sm.iterator();
synchronized(sm) {
while(it.hasNext())
}
return list;
}