kenshoo/metrics-play — pull request #2 by dwhjames (2013-12-09 22:54:54+00:00)
Title: Remove use of laziness

Pervasive use of `lazy val` leads to users of `MetricsRegistry.default` holding on to stale references, by which I mean registries that have since been removed from `SharedMetricRegistries` by `MetricsPlugin.onStop`. Play’s reloading application loads external libraries in a class loader that will not refresh on reload, so a lazy object with lazy vals will hold on to the metric registry that was created on initial app load, while the plugin’s `onStart` will create a distinct and fresh metric registry upon each app reload!

`def` must be used in favor of `lazy val` to ensure that the latest registry and configuration is accessed every time, even after an app reload occurs.

The bad behavior can be exposed when instrumenting the initialization code block for lazy vals to see exactly when initialization occurs and exactly what object has been stored.

I’ve also bumped some version numbers for dependencies in the build: Scala 2.10.2; Metrics 3.0.1; Play 2.2.1