[jboss-jira] [JBoss JIRA] (WFLY-3220) ARJUNA016009 ArrayIndexOutOfBoundsException during periodic recovery on EJBTransactionRecoveryService

Masafumi Miura (JIRA) issues at jboss.org
Fri Apr 4 14:00:13 EDT 2014


Masafumi Miura created WFLY-3220:
------------------------------------

             Summary: ARJUNA016009 ArrayIndexOutOfBoundsException during periodic recovery on EJBTransactionRecoveryService
                 Key: WFLY-3220
                 URL: https://issues.jboss.org/browse/WFLY-3220
             Project: WildFly
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: EJB
    Affects Versions: 8.0.0.Final
            Reporter: Masafumi Miura
            Assignee: David Lloyd


https://bugzilla.redhat.com/show_bug.cgi?id=1035216 is also reproducible in wildfly.

{code}
WARN  [com.arjuna.ats.jta] (Periodic Recovery) ARJUNA016009: Caught:: java.lang.ArrayIndexOutOfBoundsException: 0
	at org.jboss.as.ejb3.remote.EJBTransactionRecoveryService.getXAResources(EJBTransactionRecoveryService.java:114)
	at com.arjuna.ats.internal.jbossatx.jta.XAResourceRecoveryHelperWrapper.getXAResources(XAResourceRecoveryHelperWrapper.java:51) [narayana-jts-integration-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)]
	at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:516) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)]
	at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkFirstPass(XARecoveryModule.java:182) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)]
	at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:743) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)]
	at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)]
{code}

I think the line 111 "new XAResource\[receiverContexts.size()\]" should be placed inside synchronized block.

{code:java|title=ejb3/src/main/java/org/jboss/as/ejb3/remote/EJBTransactionRecoveryService.java}
109     @Override
110     public XAResource[] getXAResources() {
111         final XAResource[] xaResources = new XAResource[receiverContexts.size()];
112         synchronized (receiverContexts) {
113             for (int i = 0; i < receiverContexts.size(); i++) {
114                 xaResources[i] = EJBClientManagedTransactionContext.getEJBXAResourceForRecovery(receiverContexts.get(i), arjunaTxCoreEnvironmentBean.getValue().getNodeIdentifier());
115             }
116         }
117         return xaResources;
118     }
...
124     @Override
125     public void receiverRegistered(final EJBReceiverContext receiverContext) {
126         this.receiverContexts.add(receiverContext);
127     }
{code}

I think this "java.lang.ArrayIndexOutOfBoundsException: 0" will happen in the following scenario:

# receiverContexts.size() = 0 at the line 111 
xaResources is created with new XAResource\[0\]
# receiverRegistered method is called from other thread between the line 111 and 112
Now receiverContexts.size() = 1
# As receiverContexts.size() = 1, for-loop is executed
Then "xaResources\[0\] = ..." will get ArrayIndexOutOfBoundsException at  the line 114 because xaResources is empty array.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list