claudio
Aug 23rd, 2004, 08:11 AM
Hi,
today i run in following problem with the AbstractValueModel:
ValueHolder valueHolder = new ValueHolder(new Object());
valueHolder.set( new Object());
this code will throw a NullPointerException because the method set(Object o) calls fireValueChanged() and the used listeners List is not instanciated. The List member is only instanciated if a ValueListener is registered.
[ERROR] ApplicationAdvisor - null <java.lang.NullPointerException>java.lang.NullPointerException
at org.springframework.rules.values.AbstractValueMode l.fireValueChanged(AbstractValueModel.java:63)
at org.springframework.rules.values.ValueHolder.set(V alueHolder.java:40)
For the listeners i would sugest an eager instanciation, but I checked the CVS History and it was eager until the check in on 18.08.04!
Now, why it was changes to "lazy"? And what is the best solution to this problem?
- Back to eager instanciation?
- Check if not null on fireValueChanged?
- ...
siu
Claudio
today i run in following problem with the AbstractValueModel:
ValueHolder valueHolder = new ValueHolder(new Object());
valueHolder.set( new Object());
this code will throw a NullPointerException because the method set(Object o) calls fireValueChanged() and the used listeners List is not instanciated. The List member is only instanciated if a ValueListener is registered.
[ERROR] ApplicationAdvisor - null <java.lang.NullPointerException>java.lang.NullPointerException
at org.springframework.rules.values.AbstractValueMode l.fireValueChanged(AbstractValueModel.java:63)
at org.springframework.rules.values.ValueHolder.set(V alueHolder.java:40)
For the listeners i would sugest an eager instanciation, but I checked the CVS History and it was eager until the check in on 18.08.04!
Now, why it was changes to "lazy"? And what is the best solution to this problem?
- Back to eager instanciation?
- Check if not null on fireValueChanged?
- ...
siu
Claudio