Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-316

java.lang.ArrayIndexOutOfBoundsException from RemoteDelivery

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.0
    • Fix Version/s: 2.3.0
    • Component/s: Remote Delivery
    • Labels:
      None
    • Environment:
      Windows XP

      Description

      When I look in the mailet logs, I see pages and pages of errors like this:

      12/08/04 14:31:01 INFO James.Mailet: RemoteDelivery: Exception caught in RemoteDelivery.run()
      java.lang.ArrayIndexOutOfBoundsException: 10
      at org.apache.james.transport.mailets.RemoteDelivery.getNextDelay(RemoteDelivery.java:981)
      at org.apache.james.transport.mailets.RemoteDelivery.access$000(RemoteDelivery.java:93)
      at org.apache.james.transport.mailets.RemoteDelivery$MultipleDelayFilter.accept(RemoteDelivery.java:155)
      at org.apache.james.mailrepository.AvalonSpoolRepository.accept(AvalonSpoolRepository.java:156)
      at org.apache.james.transport.mailets.RemoteDelivery.run(RemoteDelivery.java:901)
      at java.lang.Thread.run(Unknown Source)
      12/08/04 14:31:01 INFO James.Mailet: RemoteDelivery: Exception caught in RemoteDelivery.run()
      java.lang.ArrayIndexOutOfBoundsException: 2
      at org.apache.james.transport.mailets.RemoteDelivery.getNextDelay(RemoteDelivery.java:981)
      at org.apache.james.transport.mailets.RemoteDelivery.access$000(RemoteDelivery.java:93)
      at org.apache.james.transport.mailets.RemoteDelivery$MultipleDelayFilter.accept(RemoteDelivery.java:155)
      at org.apache.james.mailrepository.AvalonSpoolRepository.accept(AvalonSpoolRepository.java:156)
      at org.apache.james.transport.mailets.RemoteDelivery.run(RemoteDelivery.java:901)
      at java.lang.Thread.run(Unknown Source)

      Email does not appear to be delivered, my startup is exceptionally slow, but that may be a different issue.

      1. config.xml
        46 kB
        Bradley D. Brown

        Activity

        Hide
        brownb6483 Bradley D. Brown added a comment -

        Here's my config.xml file in case I messed something up here...

        Show
        brownb6483 Bradley D. Brown added a comment - Here's my config.xml file in case I messed something up here...
        Hide
        hes Hes Siemelink added a comment -

        Same here...

        James short-circuited in the RemoteDelivery, hogging all CPU time.

        What probably happens is that it is possible to misconfigure the RemoteDelivery's delayTimes in the config.xml file. This passes undetected, but at the hour of delivering a message getNextDelay() throws the ArrayIndexOutOfBoundsException.

        This will cause a (tight) loop in RemoteDelivery.run().

        Work-around: configure your config.xml so there are less delayTimes entries than deliveryAttempts and delete all your mail that is still hanging in a queue.

        Show
        hes Hes Siemelink added a comment - Same here... James short-circuited in the RemoteDelivery, hogging all CPU time. What probably happens is that it is possible to misconfigure the RemoteDelivery's delayTimes in the config.xml file. This passes undetected, but at the hour of delivering a message getNextDelay() throws the ArrayIndexOutOfBoundsException. This will cause a (tight) loop in RemoteDelivery.run(). Work-around: configure your config.xml so there are less delayTimes entries than deliveryAttempts and delete all your mail that is still hanging in a queue.
        Hide
        hes Hes Siemelink added a comment -

        Quick fix:

        Alter the method RemoteDelivery.getNextDelay by adding a range check:

        /**

        • This method returns, given a retry-count, the next delay time to use.
        • @param retry_count the current retry_count.
        • @return the next delay time to use, given the retry count
          **/
          private long getNextDelay (int retry_count)
          Unknown macro: {+ if (retry_count >= delayTimes.length) { + return DEFAULT_DELAY_TIME; + } return delayTimes[retry_count-1]; }

        This solution will also work if the array of delayTimes shrinks because of a reconfiguration, but there is still a message with more error attempts hanging in the queue.

        We need a robust solution, because if this method throws an exception James virtually hangs!

        Show
        hes Hes Siemelink added a comment - Quick fix: Alter the method RemoteDelivery.getNextDelay by adding a range check: /** This method returns, given a retry-count, the next delay time to use. @param retry_count the current retry_count. @return the next delay time to use, given the retry count **/ private long getNextDelay (int retry_count) Unknown macro: {+ if (retry_count >= delayTimes.length) { + return DEFAULT_DELAY_TIME; + } return delayTimes[retry_count-1]; } This solution will also work if the array of delayTimes shrinks because of a reconfiguration, but there is still a message with more error attempts hanging in the queue. We need a robust solution, because if this method throws an exception James virtually hangs!
        Hide
        bago Stefano Bagnara added a comment -

        Applied the workaround. Changed the >= to >.

        Show
        bago Stefano Bagnara added a comment - Applied the workaround. Changed the >= to >.
        Hide
        danny@apache.org Danny Angus added a comment -

        Closing issue fixed in released version.

        Show
        danny@apache.org Danny Angus added a comment - Closing issue fixed in released version.

          People

          • Assignee:
            bago Stefano Bagnara
            Reporter:
            brownb6483 Bradley D. Brown
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development