details of remotely closed Sessions are not removed from the Connection

Details

Description

The Connection keeps track of its Sessions for housekeeping purposes, and previously these details have only been cleaned up fully if the Session close() method is called. If a Session is remotely closed, further attempts to use it and its resources will throw an exception as they are then marked closed. It is probable an application wont then call close() on the Session. If the application continues using the Connection in such a scenario, then the tracking details of the closed Session is retained thus leaking a small amount of memory, which if it is repeated a lot over time may eventually cause problems.

The cleanup of this information should be moved into the Session shutdown process which occurs when it is locally or remotely closed.

Original Description:
================

We use Qpid JMS to connect to the Azure service bus.

In our applications we cache the connections in a pool and cache a session for each connection for sending messages.

When Azure believes the connection is idle for 5 minutes it is remotely closed. Resulting in closing the cached session in the application. The application responds by replacing the cached session with a newly created session.

The problem here is that the closed sessions are not removed from the connection. Eventually resulting in an OutOfMemoryError.