#27 Deprecated ProxoolFacade.getDelegateConnection issues

open
Bill Horsman
6
2006-07-14
2006-04-11
Miro Halas
No

Little background: We are developing application
development framework called OpenSubsystems
(www.opensubsystems.org). We support multiple
connection pools and Proxool is one of them. We have
our own compatibility test suite to verify
functionality of the connection pools we use. We have
recently upgraded from 0.8.3 to 0.9.0RC2 and now we are
encountering issue with
ProxoolFacade.getDelegateConnection method.

Originally we had method such as this

/**
* {@inheritDoc}
*/
protected boolean containsConnection(
List lstConnections,
Connection newConnection
) throws OSSInternalErrorException
{
Connection cConnectionFromList = null;
Iterator itHelp;
boolean bReturn = false;

Connection testConn1 = null;
Connection testConn2 = null;

// for each connection from the list test if
new requested connection is
// contained in the list
itHelp = lstConnections.iterator();
while (itHelp.hasNext())
{
cConnectionFromList =
(Connection)itHelp.next();
try
{
testConn1 =
ProxoolFacade.getDelegateConnection(cConnectionFromList);
testConn2 =
ProxoolFacade.getDelegateConnection(newConnection);
bReturn = bReturn || (testConn1 ==
testConn2);
}
catch (ProxoolException peExc)
{
throw new
OSSInternalErrorException("There was an error occured
during getting" +
" the proxool connection.", peExc);
}
}

return bReturn;
}

The purpose of this method is to test if the pool
returns the same real database connection twice to
verify that it is in fact pooled as we are expecting.
We have utilized the now deprecated method
ProxoolFacade.getDelegateConnection. Now when we run
out test suite we encounter NullPointerException

java.lang.NullPointerException
at
org.logicalcobwebs.proxool.ProxyFactory.getDelegateConnection(ProxyFactory.java:104)
at
org.logicalcobwebs.proxool.ProxoolFacade.getDelegateConnection(ProxoolFacade.java:592)
at
org.opensubsystems.core.persist.db.connectionpool.ProxoolDatabaseConnectionFactoryTest$ProxoolDatabaseConnectionFactoryTestInternal.containsConnection(ProxoolDatabaseConnectionFactoryTest.java:139)
at
org.opensubsystems.core.persist.db.connectionpool.PooledDatabaseConnectionFactoryImplBaseTest.testRequestXReturnX(PooledDatabaseConnectionFactoryImplBaseTest.java:230)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at
junit.framework.TestResult$1.protect(TestResult.java:106)
at
junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at
org.opensubsystems.core.persist.db.DatabaseTestSuite.runTest(DatabaseTestSuite.java:143)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
at
junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.extensions.TestSetup.run(TestSetup.java:23)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

We would also like to remove the deprecated code. Based
on the comments in ProxoolFacade.getDelegateConnection
I have tried to modify the method to the following

/**
* {@inheritDoc}
*/
protected boolean containsConnection(
List lstConnections,
Connection newConnection
) throws OSSInternalErrorException
{
Connection cConnectionFromList = null;
Iterator itHelp;
boolean bReturn = false;

// for each connection from the list test if
new requested connection is
// contained in the list
itHelp = lstConnections.iterator();
while (itHelp.hasNext())
{
cConnectionFromList =
(Connection)itHelp.next();
bReturn = bReturn || (cConnectionFromList
== newConnection);
}

return bReturn;
}

which obviosuly doesn't work since Proxool creates
always new proxy. Would you either fix the deprecated
method getDelegateConnection so that even though it is
deprecated we can still use it in out compatibility
test suite or recommend other solution for our test.

Thanks in advance.

Discussion

  • Bill Horsman
    Bill Horsman
    2006-07-14

    • priority: 5 --> 6
    • assigned_to: nobody --> billhorsman
     
  • Bill Horsman
    Bill Horsman
    2006-07-14

    Logged In: YES
    user_id=91747

    That's a fair question. Sorry for the slow response. I'll
    look into that.