sonatype/security — pull request #29 by scarlucci (2013-04-29 03:32:19+00:00)
Title: REVIEW: Add thread-safe access to ConfigurationManager

These changes enhance the ConfigurationManager interface to allow for a thread-safe way to use the interface. Previously, access to this interface was not synchronized, and since many operations required multiple method calls, there was no way for clients to use it in a thread-safe manner. The changes introduce a reader/writer locking mechanism to ConfigurationManager.

New runRead and runWrite methods were introduced. These methods take a ConfigurationManagerAction instance, acquire the appropriate lock, and invoke the action. This allows clients to create their action to call whatever ConfigurationManager methods are needed to complete the operation, and execute them with the appropriate lock.

The goal here was to add thread-safety, while minimizing changes to the existing interface and users of the interface, and minimize the risk of introducing deadlocks. The approach taken does that by abstracting the handling of the locks from users of the interface, and by keeping the existing interface intact. This approach did introduce a complexity in dealing with the various exceptions that could be thrown from the new runRead and runWrite methods, but still seemed like the best solution.