Commons Lang
  1. Commons Lang
  2. LANG-629

Charset may not be threadsafe, because the HashSet is not synch.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Component/s: lang.*
    • Labels:
      None

      Description

      Charset may not be threadsafe, because the HashSet "set" is not synch.

      The set is only updated by the protected add() method, which is currently only used by the protected ctors.

      Perhaps add() should be private?
      This would prevent any changes to the set after construction, and might be sufficient to ensure safe publication between threads.

      Alternatively, make the set synch, as is done for COMMON.

        Activity

        Sebb created issue -
        Sebb made changes -
        Field Original Value New Value
        Description Charset may not be threadsafe, because the HashSet "set" is not synch.

        The set is only updated by the protected add() method, which is currently only used by the protected ctors.

        Given that COMMON is a synch. set, perhaps "set" should be too.

        Perhaps add() should be private?

        Charset may not be threadsafe, because the HashSet "set" is not synch.

        The set is only updated by the protected add() method, which is currently only used by the protected ctors.

        Perhaps add() should be private?
        This would prevent any changes to the set after construction, and might be sufficient to ensure safe publication between threads.

        Alternatively, make the set synch, as is done for COMMON.

        Henri Yandell made changes -
        Component/s lang.* [ 12313203 ]
        Hide
        Henri Yandell added a comment -

        I've gone with simply making the underlying set synchronized.

        svn ci -m "Per LANG-629, making the underlying set synchronized for CharSet"
        Sending src/main/java/org/apache/commons/lang3/CharSet.java
        Transmitting file data .
        Committed revision 998000.

        Show
        Henri Yandell added a comment - I've gone with simply making the underlying set synchronized. svn ci -m "Per LANG-629 , making the underlying set synchronized for CharSet" Sending src/main/java/org/apache/commons/lang3/CharSet.java Transmitting file data . Committed revision 998000.
        Henri Yandell made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        Mark Thomas made changes -
        Workflow jira [ 12514743 ] Default workflow, editable Closed status [ 12602493 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        77d 21h 40m 1 Henri Yandell 17/Sep/10 08:18

          People

          • Assignee:
            Unassigned
            Reporter:
            Sebb
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development