Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-13447

Undertow request failure happens due to "IllegalArgumentException: Comparison method violates its general contract!" when many filter-ref are defined

XMLWordPrintable

    • Hide

      1. Execute the attached "generate-cli.sh" to generate JBoss CLI script (test.cli) which configures many filter-ref definistion.
      2. Execute the generated "test.cli"

      ./bin/jboss-cli.sh --file=/path/to/test.cli
      

      3. Start JBoss EAP 7 with the configuration

      ./bin/standalone.sh -c standalone-test.xml
      

      4. Send a request

      curl -v http://localhost:8080/
      

      The request fails with "500 Internal Server Error" because of "IllegalArgumentException: Comparison method violates its general contract!"

      Show
      1. Execute the attached "generate-cli.sh" to generate JBoss CLI script (test.cli) which configures many filter-ref definistion. 2. Execute the generated "test.cli" ./bin/jboss-cli.sh --file=/path/to/test.cli 3. Start JBoss EAP 7 with the configuration ./bin/standalone.sh -c standalone-test.xml 4. Send a request curl -v http: //localhost:8080/ The request fails with "500 Internal Server Error" because of "IllegalArgumentException: Comparison method violates its general contract!"
    • Hide

      If you really need to define many filter-ref definition, you can work around this issue by adding the following to JAVA_OPTS in standalone.conf:

      JAVA_OPTS="$JAVA_OPTS -Djava.util.Arrays.useLegacyMergeSort=true"
      
      Show
      If you really need to define many filter-ref definition, you can work around this issue by adding the following to JAVA_OPTS in standalone.conf: JAVA_OPTS= "$JAVA_OPTS -Djava.util.Arrays.useLegacyMergeSort= true "

      When many filter-ref are defined (theoretically more than 32 filter-ref are defined), Undertow has a possibility fail to process a request with the following ERROR:

      ERROR [io.undertow.request] (default I/O-12) UT005071: Undertow request failed HttpServerExchange{ GET /}: java.lang.IllegalArgumentException: Comparison method violates its general contract!
      	at java.util.TimSort.mergeLo(TimSort.java:777)
      	at java.util.TimSort.mergeAt(TimSort.java:514)
      	at java.util.TimSort.mergeCollapse(TimSort.java:441)
      	at java.util.TimSort.sort(TimSort.java:245)
      	at java.util.Arrays.sort(Arrays.java:1512)
      	at java.util.ArrayList.sort(ArrayList.java:1462)
      	at org.wildfly.extension.undertow.LocationService.configureHandlerChain(LocationService.java:93)
      	at org.wildfly.extension.undertow.Host.configureRootHandler(Host.java:174)
      	at org.wildfly.extension.undertow.Host.getOrCreateRootHandler(Host.java:263)
      	at org.wildfly.extension.undertow.Host$HostRootHandler.handleRequest(Host.java:430)
      	at io.undertow.server.handlers.NameVirtualHostHandler.handleRequest(NameVirtualHostHandler.java:54)
      	at io.undertow.server.handlers.error.SimpleErrorPageHandler.handleRequest(SimpleErrorPageHandler.java:78)
      	at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
      	at org.wildfly.extension.undertow.Server$DefaultHostHandler.handleRequest(Server.java:190)
      	at io.undertow.server.handlers.ChannelUpgradeHandler.handleRequest(ChannelUpgradeHandler.java:211)
      	at io.undertow.server.protocol.http2.Http2UpgradeHandler.handleRequest(Http2UpgradeHandler.java:102)
      	at io.undertow.server.handlers.DisallowedMethodsHandler.handleRequest(DisallowedMethodsHandler.java:61)
      	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370)
      	at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:255)
      	at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
      	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:162)
      	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:100)
      	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:57)
      	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
      	at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:291)
      	at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:286)
      	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
      	at org.xnio.nio.QueuedNioTcpServer2.acceptTask(QueuedNioTcpServer2.java:178)
      	at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:612)
      	at org.xnio.nio.WorkerThread.run(WorkerThread.java:479)
      

      The IllegalArgumentException happens when Java's TimSort algorithm happens to detect inconsistency in the comparison. This happens because the comparator implementation for sorting filter-ref does not follow the contract for comparison.

        1. generate-cli.sh
          0.6 kB
        2. test.cli
          60 kB

              rhn-support-mmiura Masafumi Miura
              rhn-support-mmiura Masafumi Miura
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: