spring-projects/spring-boot — pull request #543 by nicholashagen (2014-03-21 21:16:36+00:00)
Title: CodahaleMetricWriter fails under load test due to parallel access to writer and gauges

The MetricFilter that delegates to the CodahaleMetricWriter fails when taking several parallel requests to the same URL as it tries to update a gauge which causes a ``registry.remove`` followed by ``registry.register``. The latter fails if two threads call ``register`` back to back as the first will register and the second will fail as having already been registered.

This pull request adds a test case showcasing the error and offers a fix by synchronizing on the registry. Synchronizing is not the best choice due to blocking in the parallism, but I do not see a better way to avoid the error scenario with the API that Codahale exposes.