Mule
  1. Mule
  2. MULE-5161

ArrayIndexOutOfBoundsException in CopyOnWriteArrayList

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 3.0.1
    • Labels:
      None
    • User impact:
      High
    • Configuration:
      Hide

      <?xml version="1.0" encoding="UTF-8"?>
      <mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
      xmlns:spring="http://www.springframework.org/schema/beans"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
      http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.0/mule-vm.xsd
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd">
      <endpoint name="inbound.sync" address="vm://test.inbound.sync"/>
      <flow name="flowTestSync">
      <inbound-endpoint ref="inbound.sync" exchange-pattern="request-response"/>
      <!-- don't use the Mule echo-component; it will corrupt your byte[] messages -->
      <component class="EchoBytes"/>
      </flow>
      </mule>

      Show
      <?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:spring="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.0/mule-vm.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd "> <endpoint name="inbound.sync" address="vm://test.inbound.sync"/> <flow name="flowTestSync"> <inbound-endpoint ref="inbound.sync" exchange-pattern="request-response"/> <!-- don't use the Mule echo-component; it will corrupt your byte[] messages --> <component class="EchoBytes"/> </flow> </mule>
    • Log Output:
      Hide
      Root Exception stack trace:
      java.lang.ArrayIndexOutOfBoundsException: 0
      at edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList.search(CopyOnWriteArrayList.java:68)
      at edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList.addIfAbsent(CopyOnWriteArrayList.java:131)
      at edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArraySet.add(CopyOnWriteArraySet.java:223)
      at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:57)
      at org.mule.component.DefaultComponentLifecycleAdapter.invoke(DefaultComponentLifecycleAdapter.java:350)
      at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:90)
      at org.mule.component.AbstractJavaComponent.doInvoke(AbstractJavaComponent.java:81)
      at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:113)
      at org.mule.component.AbstractComponent.access$000(AbstractComponent.java:51)
      at org.mule.component.AbstractComponent$1.process(AbstractComponent.java:241)
      at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65)
      at org.mule.component.AbstractComponent.process(AbstractComponent.java:146)
      at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65)
      at org.mule.construct.AbstractFlowConstruct$1$1.process(AbstractFlowConstruct.java:103)
      at org.mule.processor.ExceptionHandlingMessageProcessor.process(ExceptionHandlingMessageProcessor.java:22)
      at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65)
      at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65)
      at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:187)
      at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:160)
      at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:147)
      at org.mule.transport.vm.VMMessageReceiver.onCall(VMMessageReceiver.java:109)
      at org.mule.transport.vm.VMMessageDispatcher$1.doInTransaction(VMMessageDispatcher.java:89)
      at org.mule.transport.vm.VMMessageDispatcher$1.doInTransaction(VMMessageDispatcher.java:86)
      at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:110)
      at org.mule.transport.vm.VMMessageDispatcher.doSend(VMMessageDispatcher.java:92)
      at org.mule.transport.AbstractMessageDispatcher.process(AbstractMessageDispatcher.java:75)
      at org.mule.transport.AbstractConnector$DispatcherMessageProcessor.process(AbstractConnector.java:2558)
      at org.mule.endpoint.outbound.OutboundResponsePropertiesMessageProcessor.process(OutboundResponsePropertiesMessageProcessor.java:39)
      at org.mule.processor.TransactionalInterceptingMessageProcessor$1.doInTransaction(TransactionalInterceptingMessageProcessor.java:49)
      at org.mule.processor.TransactionalInterceptingMessageProcessor$1.doInTransaction(TransactionalInterceptingMessageProcessor.java:46)
      at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:110)
      at org.mule.processor.TransactionalInterceptingMessageProcessor.process(TransactionalInterceptingMessageProcessor.java:55)
      at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:41)
      at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65)
      at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65)
      at org.mule.endpoint.DefaultOutboundEndpoint.process(DefaultOutboundEndpoint.java:88)
      at org.mule.module.client.MuleClient.send(MuleClient.java:643)
      at org.mule.module.client.MuleClient.send(MuleClient.java:619)
      at org.mule.module.client.MuleClient.send(MuleClient.java:570)
      at NpeTestCase$ClientRequest.run(NpeTestCase.java:58)
      Show
      Root Exception stack trace: java.lang.ArrayIndexOutOfBoundsException: 0 at edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList.search(CopyOnWriteArrayList.java:68) at edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList.addIfAbsent(CopyOnWriteArrayList.java:131) at edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArraySet.add(CopyOnWriteArraySet.java:223) at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:57) at org.mule.component.DefaultComponentLifecycleAdapter.invoke(DefaultComponentLifecycleAdapter.java:350) at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:90) at org.mule.component.AbstractJavaComponent.doInvoke(AbstractJavaComponent.java:81) at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:113) at org.mule.component.AbstractComponent.access$000(AbstractComponent.java:51) at org.mule.component.AbstractComponent$1.process(AbstractComponent.java:241) at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65) at org.mule.component.AbstractComponent.process(AbstractComponent.java:146) at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65) at org.mule.construct.AbstractFlowConstruct$1$1.process(AbstractFlowConstruct.java:103) at org.mule.processor.ExceptionHandlingMessageProcessor.process(ExceptionHandlingMessageProcessor.java:22) at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65) at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65) at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:187) at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:160) at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:147) at org.mule.transport.vm.VMMessageReceiver.onCall(VMMessageReceiver.java:109) at org.mule.transport.vm.VMMessageDispatcher$1.doInTransaction(VMMessageDispatcher.java:89) at org.mule.transport.vm.VMMessageDispatcher$1.doInTransaction(VMMessageDispatcher.java:86) at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:110) at org.mule.transport.vm.VMMessageDispatcher.doSend(VMMessageDispatcher.java:92) at org.mule.transport.AbstractMessageDispatcher.process(AbstractMessageDispatcher.java:75) at org.mule.transport.AbstractConnector$DispatcherMessageProcessor.process(AbstractConnector.java:2558) at org.mule.endpoint.outbound.OutboundResponsePropertiesMessageProcessor.process(OutboundResponsePropertiesMessageProcessor.java:39) at org.mule.processor.TransactionalInterceptingMessageProcessor$1.doInTransaction(TransactionalInterceptingMessageProcessor.java:49) at org.mule.processor.TransactionalInterceptingMessageProcessor$1.doInTransaction(TransactionalInterceptingMessageProcessor.java:46) at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:110) at org.mule.processor.TransactionalInterceptingMessageProcessor.process(TransactionalInterceptingMessageProcessor.java:55) at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:41) at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65) at org.mule.processor.builder.InterceptingChainCompositeMessageProcessor.process(InterceptingChainCompositeMessageProcessor.java:65) at org.mule.endpoint.DefaultOutboundEndpoint.process(DefaultOutboundEndpoint.java:88) at org.mule.module.client.MuleClient.send(MuleClient.java:643) at org.mule.module.client.MuleClient.send(MuleClient.java:619) at org.mule.module.client.MuleClient.send(MuleClient.java:570) at NpeTestCase$ClientRequest.run(NpeTestCase.java:58)
    • Similar Issues:
      None

      Description

      The clear() method of the edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList is NOT synchronized (it should be). This causes a race condition in the Mule DefaultEntryPointResolverSet that leads to sporadic ArrayIndexOutOfBoundsExceptions.

      Can be reprocuded with this FunctionalTestCase:

      import org.mule.api.MuleException;
      import org.mule.api.MuleMessage;
      import org.mule.module.client.MuleClient;
      import org.mule.tck.FunctionalTestCase;
      import org.mule.util.Base64;

      import java.util.List;
      import java.util.Random;

      public class NpeTestCase extends FunctionalTestCase {

      @Override
      protected String getConfigResources()

      { return "npe-test-config.xml"; }

      public void testMultithreaded() throws Exception {
      final int numberOfThreads = 50;
      final int requestCount = 100;
      ClientRequest[] clients = new ClientRequest[numberOfThreads];
      for (int i = 0; i < numberOfThreads; i++)

      { clients[i] = new ClientRequest(requestCount); }

      for (ClientRequest clientRequest : clients) {
      clientRequest.start();
      try

      { Thread.sleep(5); }

      catch (InterruptedException ignored) {}
      }

      for (int i = 0; i < numberOfThreads; i++) {
      try

      { clients[i].join(); }

      catch (InterruptedException ignored) {}
      }
      }

      private class ClientRequest extends Thread {
      final MuleClient client;
      int requestCount;

      private ClientRequest(final int requestCount) throws MuleException

      { client = new MuleClient(muleContext); this.requestCount = requestCount; }

      @Override
      public void run() {
      final byte[] payload = createPayload();

      while (--requestCount >= 0) {
      try {
      final MuleMessage outbound = client.send("inbound.sync", payload, null);
      assertNull(outbound.getExceptionPayload());
      assertNotNull(outbound.getPayload());
      byte[] bytes = null;
      if (outbound.getPayload() instanceof byte[])

      { bytes = (byte[]) outbound.getPayload(); }

      else if (outbound.getPayload() instanceof List)

      { final List list = (List)outbound.getPayload(); assertEquals(1, list.size()); assertTrue(list.get(0) instanceof byte[]); bytes = (byte[]) list.get(0); }

      else

      { fail("unexpected payload type"); }

      assertEquals(Base64.encodeBytes(payload), Base64.encodeBytes(bytes));
      }
      catch (Exception e)

      { fail("failed with exception: " + e); }

      }
      }

      private byte[] createPayload()

      { Random random = new Random(); final int size = 55; byte[] payload = new byte[size]; random.nextBytes(payload); return payload; }

      }
      }

      1. NpeTestCase.java
        3 kB
        achim pfefferle
      2. npe-test-config.xml
        1.0 kB
        achim pfefferle

        Issue Links

          Activity

          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          To Do To Do In Progress In Progress
          8d 12h 31m 1 Dirk Olmes 02/Nov/10 04:34 PM
          In Progress In Progress Closed Closed
          2d 10h 18m 1 Dirk Olmes 05/Nov/10 02:52 AM

            People

            • Assignee:
              Dirk Olmes
              Reporter:
              achim pfefferle
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                12/Nov/10

                Development