Skip to content

@Shared property that is overridden in derived class causes problems #203

@robfletcher

Description

@robfletcher

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions