Originally reported on Google Code with ID 81
class CleanInsertXSpec extends Specification {
@Shared
@Inject
Things thingFactory
...
void setup() {
thingFactory.xxxxxx --> NullPointerException()
}
....
}
class Y extends CleanInsertXSpec {
ThingFactory thingFactory = new ThingFactory()
}
@Shared turns field access thingFactory.xxx into property access, and getter is overridden
in
derived class. Thus we end up accessing the wrong field (and that field isn't initialized
yet). One
(brute force) way around this might be to make getter/setter of @Shared properties
private.
Reported by pniederw on 2010-03-09 19:08:46