Statistics using ExecutionAttributes are inaccessible?
I'm using m4, and trying to store statistics in a context aware ItemWriter, using context.setAttribute.
When I try to fetch the statistics i get nothing back.
Using a debugger I noticed that SimpleStepContext gets registered using itself as the key. SimpleStepContext gets its hashCode implementation from SynchronizedAttributeAccessor which delegates to AttributeAccessorSupport and eventually to LinkedHashMap. The hashCode calculated by LinkedHashMap is based on the items the map contains, and will therefore change whenever items are added.
This means that if you add items to the map (which setAttribute does) after it has been registered, you will never be able to take it out (the map will look in the wrong bucket).
Am I doing this wrong or is this a bug?