Rickard Oberg wrote:
>> Assume that a Connection instance was got in the bean method and
>> then was not closed due to error, i.e. it wasn't assigned to
>> an instance field. I would expect that in this case JVM Garbage
>> Collector would collect the Connection instance and call finalize()
>> that in turn would call close().
RO> finalize() doesn't seem to be implemented in the ConnectionInPool wrapper.
RO> Could this be the easy fix to do?
I think it definitely should be done.
But when I encountered the problem, I was using your DataSourceImpl,
which has its own pool and don't seems to work with ConnectionInPool.
And the wrapper is ConnectionProxy, which should pass finalize() call
to the underlying Connection. That is why I cannot explain the
behavior that I saw.
>> Assume, that I am right and some reference remains.
>> Maybe, the problem would be solved if all such referenced was replaced
>> by WeakReferences (and HashMaps by WeakHashMaps).
RO> Then we would essentially be back to the problem of "overhead per call" as
RO> outlined by Aaron since we have to make sure that a call invocation actually
RO> has a connection to work with.
And I answer you as you answered to Aaron: the overhead would be minor
:-)
Best regards,
Oleg