Discussion:
Problems with named setter injection
Martin Fuzzey
2008-06-23 16:39:06 UTC
Permalink
Hi,
I'm having weird problems with named setter injection.
The attached test case demonstrates this.

The problem occurs when a class requires the injection of two objects
of the same type (disambiguated by USE_NAMES) _and_ another object.
Depending on the declaration order of the setters it works or fails.
I think this is related to the method
IterativeInjector.getMatchingParameterListForSetters() which contains
two nested loops that seem to mismatch types..

The test case also shows another strange behaviour :
it contains two tests, testGood and testBad which invoke the same code
on two classes GoodTarget and BadTarget whose only difference is the
order of the setters.

If just testGood is run it passes [normal]
if just testBad is run it fails [the problem]
if testGood then testBad are run they both pass [!!}
if testBad then testGood are run they both fail... [!!]

This is inspite of each test creating its own picocontainer instance.
Looks like some data is being kept around (static fields??)

Martin
Paul Hammant
2008-06-23 19:49:14 UTC
Permalink
That is interesting Martin.

I'll try to work thru it later ...

- Paul
Post by Martin Fuzzey
Hi,
I'm having weird problems with named setter injection.
The attached test case demonstrates this.
The problem occurs when a class requires the injection of two objects
of the same type (disambiguated by USE_NAMES) _and_ another object.
Depending on the declaration order of the setters it works or fails.
I think this is related to the method
IterativeInjector.getMatchingParameterListForSetters() which contains
two nested loops that seem to mismatch types..
it contains two tests, testGood and testBad which invoke the same code
on two classes GoodTarget and BadTarget whose only difference is the
order of the setters.
If just testGood is run it passes [normal]
if just testBad is run it fails [the problem]
if testGood then testBad are run they both pass [!!}
if testBad then testGood are run they both fail... [!!]
This is inspite of each test creating its own picocontainer instance.
Looks like some data is being kept around (static fields??)
Martin
<
MultiTestCase
.java
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Paul Hammant
2008-06-25 13:26:06 UTC
Permalink
I'm not sure if you noticed dude, but we fixed this bug yesterday ..

sorry for inconvenience and thanks a bunch for writing the test.

- Paul
Post by Martin Fuzzey
Hi,
I'm having weird problems with named setter injection.
The attached test case demonstrates this.
The problem occurs when a class requires the injection of two objects
of the same type (disambiguated by USE_NAMES) _and_ another object.
Depending on the declaration order of the setters it works or fails.
I think this is related to the method
IterativeInjector.getMatchingParameterListForSetters() which contains
two nested loops that seem to mismatch types..
it contains two tests, testGood and testBad which invoke the same code
on two classes GoodTarget and BadTarget whose only difference is the
order of the setters.
If just testGood is run it passes [normal]
if just testBad is run it fails [the problem]
if testGood then testBad are run they both pass [!!}
if testBad then testGood are run they both fail... [!!]
This is inspite of each test creating its own picocontainer instance.
Looks like some data is being kept around (static fields??)
Martin
<
MultiTestCase
.java
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...