I found the broker leak in OJB, it was because getBroker() was being called on a
closed transaction.
here's what I propose to change it to, the comment explains the reasoning:
/**
* Gets the broker associated with the transaction.
* MBAIRD: only return the associated broker if the transaction is open,
* if it's closed, throw a TransactionNotInProgressException. If we allow
* brokers to be reaquired by an already closed transaction, there is a
* very good chance the broker will be leaked as the doClose() method of
* transactionImpl will never be called and thus the broker will never
* be closed and returned to the pool.
* @return Returns a PersistenceBroker
* @throws TransactionNotInProgressException is the transaction is closed;
*/
public PersistenceBroker getBroker()
{
if (this.isOpen())
{
if (broker == null)
{
try
{
broker =
PersistenceBrokerFactory.createPersistenceBroker(curDB.getPBKey());
}
catch (PBFactoryException e)
{
log.error("Cannot obtain PersistenceBroker from
PersistenceBrokerFactory, " +
curDB != null ? " PBKey was " +
curDB.getPBKey() : " Database was null", e);
throw new PersistenceBrokerException(e);
}
}
}
else
{
throw new TransactionNotInProgressException("Cannot getBroker from a
closed Transaction");
}
return broker;
}
the reason I'm posting this to the group is, potentially there is client code that
will try and get a broker from a closed transaction, this code will start to throw.
There were 3 test cases I had to change to make this work.
thoughts?
Matthew
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>