SpringSource/spring-integration — pull request #463 by garyrussell (2012-05-30 22:02:25+00:00)
Title: INT-2592 Fix Memory Leak in SimpleMessageStore

https://jira.springsource.org/browse/INT-2592

__Note: May be easier to review on the command line
with 'git log -p -b' because locking code changed
the indentation of the business code.__

Locks used to control access to a group of messages were
never removed from the collection.

Converted to use LockRegistry, which (by default) uses
a pool of reentrant locks, using the hashcode of the group id
as an index into the pool.

Given that the pool is fixed, there is nothing to remove, thus
avoiding the memory leak.

When used within AbstractCorrelatingMessageHandler, any
custom LockRegistry supplied will also be used by the message
store, thus allowing the user to increase or decrease the
size of the lock pool. The registry can not be changed
once the SimpleMessageGroup has been used.

Also, the ACMH had some protection to avoid setting the
LockRegistry more than once, but this did not protect
against the default lock registry being replaced after
it had been used. Added additional protection to avoid
this condition by setting lockRegistrySet to true in
onInit().