Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3796

Error at setting character encoding if the parameters have been already read

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 2.3.1.2
    • 2.3.3
    • Dispatch Filter
    • Glassfish

    • Patch

    Description

      In my application I have an access log filter that logs all incoming requests and the parameters of the request.
      The struts2 filter calls request.setCharacterEncoding(encoding), which results in an error, because the request encoding cannot be set after the parameters have been read. This pollutes the log with errors for every request.
      I cannot put the access log filter after the struts2 filter, because it does not invoke chain.doFilter() for the actions.
      I have a custom filter before the access log filter that sets the request encoding in advance. Struts2 tries to set the encoding again later, but too late in my case.
      The proposed patch is very simple and straightforward, and would solve my problem with the polluted log. If the encoding is already set to the same value, do not try to set it again. It is useless and will cause an error. In all other cases, set it as now.

      Attachments

        1. WW-3796.diff
          0.9 kB
          Pelladi Gabor

        Activity

          People

            lukaszlenart Lukasz Lenart
            pelladi Pelladi Gabor
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: