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

Setting the response encoding via Filter doesn't work, is always null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • 8.0.0.Beta1
    • Web (Undertow)

      When trying to set the character encoding of the HTTP response, the encoding stays null.

      This is our filter implementation:

      public void doFilter(HttpServletRequest request, HttpServletResponse response, HttpSession session,
      FilterChain chain) throws ServletException, IOException
      {
      System.out.println("encoding is " + request.getCharacterEncoding());
      if (request.getCharacterEncoding() == null)

      { request.setCharacterEncoding("UTF-8"); }

      if (request.getCharacterEncoding() == null)

      { System.out.println("could not set encoding"); Thread.dumpStack(); }

      chain.doFilter(request, response);
      }

      The stack trace implies that there is only undertow beneath us Some element in the chain has already touched the response.

      could not set encoding
      java.lang.Exception: Stack trace
      at java.lang.Thread.dumpStack(Thread.java:1342)
      at de.mdkgmbh.sp.MdkCharacterEncodingFilter.doFilter(MdkCharacterEncodingFilter.java:24)
      at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:75)
      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:56)
      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
      at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
      at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:59)
      at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
      at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:81)
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
      at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
      at io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52)
      at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
      at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:65)
      at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:70)
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
      at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:218)
      at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:205)
      at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:69)
      at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:134)
      at io.undertow.server.HttpHandlers.executeRootHandler(HttpHandlers.java:36)
      at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:619)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:722)

      We need a solution for this, as we rely on UTF-8.

      We have found no way to configure the listener either, seeing that the old JBoss Web way doesn't work anymore (WFLY-2276)

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              dxmann73@gmail.com David Mann (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: