Uploaded image for project: 'Commons Codec'
  1. Commons Codec
  2. CODEC-232

URLCodec is neither immutable nor threadsafe

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.10
    • 1.11
    • None

    Description

      URLCodec Javadoc says the class is immutable and threadsafe.

      However it is not immutable, because of the fields:

      protected static final BitSet WWW_FORM_URL;
      protected String charset;

      Nor is it threadsafe, because external code can change the charset field; changes to the field are not safely published across threads.

      (The WWW_FORM_URL field is no longer used internally).

      The class could be made effectively immutable (and threadsafe) by also saving the initial charset name in a private final field and only using the private field.

      Or the charset field could be made volatile.
      This would preserve the behaviour for subclasses that rely on changing the charset field.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sebb Sebb
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: