Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-486

BeanHelper.setDefaultBeanFactory() is thread-hostile and not thread-safe

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None

      Description

      BeanHelper.setDefaultBeanFactory() sets a private static field.

      This is thread-hostile, because different threads cannot safely use different factories.

      It's also not thread-safe, as the variable is not guaranteed to be published safely.
      Should either make the variable volatile, or synchronize both getter and setter.

        Issue Links

          Activity

          Hide
          Oliver Heger added a comment -

          Agreed. Do you want to go ahead and fix this?

          Show
          Oliver Heger added a comment - Agreed. Do you want to go ahead and fix this?
          Hide
          Sebb added a comment -

          Fixing the thread-safety issue is trivial.

          However, the class will still be potentially thread-hostile, depending on when the setter and getter are used.

          Fixing that might require a redesign of the code.

          Show
          Sebb added a comment - Fixing the thread-safety issue is trivial. However, the class will still be potentially thread-hostile, depending on when the setter and getter are used. Fixing that might require a redesign of the code.
          Hide
          Sebb added a comment -

          Same problem with AbstractConfiguration.defaultListDelimiter

          Show
          Sebb added a comment - Same problem with AbstractConfiguration.defaultListDelimiter
          Hide
          Sebb added a comment -

          ALso FileSystem.fileSystem

          Show
          Sebb added a comment - ALso FileSystem.fileSystem
          Hide
          Sebb added a comment -

          HierarchicalConfiguration.defaultExpressionEngine

          Show
          Sebb added a comment - HierarchicalConfiguration.defaultExpressionEngine
          Hide
          Oliver Heger added a comment -

          Unfortunately, the library was designed initially without thread-safety in mind I think, this should be an important topic for version 2.0.

          Show
          Oliver Heger added a comment - Unfortunately, the library was designed initially without thread-safety in mind I think, this should be an important topic for version 2.0.
          Hide
          Oliver Heger added a comment -

          Created a specific issue for dealing with BeanHelper.

          Show
          Oliver Heger added a comment - Created a specific issue for dealing with BeanHelper .
          Hide
          Oliver Heger added a comment -

          All points mentioned in this ticket have now been addressed.

          Default values are no longer set using static member fields; alternatives have been created.

          Show
          Oliver Heger added a comment - All points mentioned in this ticket have now been addressed. Default values are no longer set using static member fields; alternatives have been created.

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development