Hello All
There is very Weird problem on the PersistenceBroker :
- Allocate a new Broker
- Get something on it ( iterator by query or identity ... )
- Let the GC free the broker
- Request a new broker with the same PBKey
- Make the same request
** an Exception is throw Socket Close exception
Using latest Oracle 9i driver for 1.4 and thin driver
OJB RC05
org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl
JRE 1.4.2.02
Is Somebody can help me .
THX
Thierry
Here is my test case
WeakReference ref = null;
PBKey key =
PersistenceBrokerFactory.defaultPersistenceBroker().getPBKey();
PersistenceBroker broker =
PersistenceBrokerFactory.createPersistenceBroker(key);
// GET SOMETHING
Query q =
QueryFactory.newQuery(
DbObjectFactory.instance().getTwtzonesetsClass(),
(Criteria) null);
broker.getObjectByQuery(q);
// GET IS DONE
// ENABLE GC FOR RELEASING PB
// if a broker.close() is done , the test is working fine .
// KEEP A REF FOR BEING SUR OF PB RELEASE BY GC
ref = new WeakReference(broker);
broker = null;
System.gc();
System.gc();
System.gc();
Thread.sleep(1000);
System.gc();
System.gc();
System.gc();
Thread.sleep(1000);
Object o = ref.get();
// NORMALLY THE BROKER IS RELEASE REF IS NULL
assertTrue(o == null);
// RETRIEVE A NEW BROKER
broker = PersistenceBrokerFactory.createPersistenceBroker(key);
q =
QueryFactory.newQuery(
DbObjectFactory.instance().getTwtzonesetsClass(),
(Criteria) null);
// HERE AN EXCEPTION IS THROW : Socket Close exception
broker.getObjectByQuery(q);