Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-4820

ArrayIndexOutOfBoundsException when calling to addExchangeCompleteListener

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 7.0.1.CR1, 7.0.1.GA
    • 7.0.0.GA
    • Undertow
    • None
    • EAP 7.0.1

    Description

      Here is an exception that occurs periodically (honestly speaking it's hardly possible to reproduce it in a guaranteed way)

      2016-04-20 10:39:40,558 | ERROR | XNIO-1 task-4 | io.undertow.request | Undertow request failed HttpServerExchange{ POST / request {X-Real-IP=[86.25.131.163], Accept=[*/*], Accept-Language=[ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4], Accept-Encoding=[gzip, deflate], Origin=[https://www.host.com], User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36], X-Forwarded-For=[86.25.131.163], Content-Length=[57], Content-Type=[text/plain;charset=UTF-8], Cookie=[_ym_uid=1460350644242557907; uid=644a6af0-ffaa-11e5-a3c9-901b0e8b2a6e; _gat=1; _dc_gtm_gtmjs=1; _ym_isad=2; _ym_visorc_20986729=w; WT_FPC=id=bce3f8ce-a2b6-4dad-a70a-bd258f1e0d90:lv=1461130778506:ss=1461130243098; _ga=GA1.2.357112737.1460350644], Referer=[https://www.host.com/step2], Host=[host]} response {}}
      java.lang.ArrayIndexOutOfBoundsException: -1
              at io.undertow.server.HttpServerExchange.addExchangeCompleteListener(HttpServerExchange.java:898) ~[undertow-core-1.3.0.Final.jar:1.3.0.Final]
              at com.company.handler.SendKafkaHandler.handleRequest(SendKafkaHandler.java:67) ~[cleverdata-dmpkit-tracking-pixel-1.0.5-SNAPSHOT.jar:1.0.5-SNAPSHOT]
              at com.company.handler.ContentHandler.handleRequest(ContentHandler.java:126) ~[cleverdata-dmpkit-tracking-pixel-1.0.5-SNAPSHOT.jar:1.0.5-SNAPSHOT]
              at com.company.handler.CookiesSupportedHandler.handleRequest(CookiesSupportedHandler.java:56) ~[cleverdata-dmpkit-tracking-pixel-1.0.5-SNAPSHOT.jar:1.0.5-SNAPSHOT]
              at com.company.handler.MetricsHandler.handleRequest(MetricsHandler.java:57) ~[cleverdata-dmpkit-tracking-pixel-1.0.5-SNAPSHOT.jar:1.0.5-SNAPSHOT]
              at com.company.handler.DispatchHandler.handleRequest(DispatchHandler.java:31) ~[cleverdata-dmpkit-tracking-pixel-1.0.5-SNAPSHOT.jar:1.0.5-SNAPSHOT]
              at io.undertow.server.Connectors.executeRootHandler(Connectors.java:198) [undertow-core-1.3.0.Final.jar:1.3.0.Final]
              at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:784) [undertow-core-1.3.0.Final.jar:1.3.0.Final]
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_72]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_72]
              at java.lang.Thread.run(Thread.java:745) [?:1.8.0_72]
      

      And here is the very last handler that calls addExchangeCompleteListener.

      public class SendKafkaHandler extends BaseHandler {
          ...
          private final HttpHandler next;
      
          @Override
          public void handleRequest(HttpServerExchange exchange) throws Exception {
              exchange.addExchangeCompleteListener(completionListener);
              if (next != null) {
                  next.handleRequest(exchange);
              }
          }
          ...
      }
      

      The call to addExchangeCompleteListener occurs from the worker thread.

      And here is how exchange handling is passed from the I/O thread to the worker thread.

      public class DispatchHandler implements HttpHandler {
      
          private final HttpHandler next;
      
          public DispatchHandler(HttpHandler next) {
              if (next == null) {
                  throw new IllegalArgumentException("next: null");
              }
              this.next = next;
          }
      
          @Override
          public void handleRequest(HttpServerExchange exchange) throws Exception {
              if(exchange.isInIoThread()) {
                  exchange.dispatch(this);
                  return;
              }
              next.handleRequest(exchange);
          }
          ...
      }
      

      The issue seems to look like some kind of concurrency bug, but it's pretty difficult to say, as it happens periodically (once or twice a day, although we are having average load 1200-1500 requests per second)

      Attachments

        Issue Links

          Activity

            People

              sdouglas1@redhat.com Stuart Douglas
              szhem Sergey Zhemzhitsky (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: