MyFaces Core
  1. MyFaces Core
  2. MYFACES-3475

[perf] Improve performance of HtmlResponseWriterImpl constructor

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.0.12, 2.1.6
    • Fix Version/s: 2.0.13, 2.1.7
    • Component/s: None
    • Labels:
      None

      Description

      HtmlResponseWriterImpl is a very light object created many times. But its constructor uses a memory intensive test if character encoding is valid:

      // validates the encoding, it will throw an UnsupportedEncodingException if the encoding is invalid
      try

      { new String("myfaces".getBytes(), characterEncoding); }

      catch (UnsupportedEncodingException e)

      { throw new IllegalArgumentException("Unsupported encoding: "+characterEncoding); }

      this code is number 1. of byte [] allocations in my tests.

      We can probably remove this check entirely: a exception will be thrown a few moments later if encoding is not supported

      Review other code in constructor too - it must be fast as possible.

        Activity

        Leonardo Uribe made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Leonardo Uribe made changes -
        Fix Version/s 2.1.7 [ 12319845 ]
        Resolution Fixed [ 1 ]
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Fix Version/s 2.0.13 [ 12319847 ]
        Hide
        Leonardo Uribe added a comment -

        The check had sense in JSF 1.2/1.1, because in that time there was no standard way to handle ajax, and this was one way to check if everything was working correctly.

        It is ok to remove it. Thanks to Martin Koci for provide this patch.

        Show
        Leonardo Uribe added a comment - The check had sense in JSF 1.2/1.1, because in that time there was no standard way to handle ajax, and this was one way to check if everything was working correctly. It is ok to remove it. Thanks to Martin Koci for provide this patch.
        Martin Kočí made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Martin Kočí made changes -
        Field Original Value New Value
        Attachment MYFACES-3475.patch [ 12515963 ]
        Martin Kočí created issue -

          People

          • Assignee:
            Martin Kočí
            Reporter:
            Martin Kočí
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development