You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2006/03/21 21:14:53 UTC
DO NOT REPLY [Bug 39052] New: - NullPointerException returning obj to pool during shutdown
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39052>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39052
Summary: NullPointerException returning obj to pool during
shutdown
Product: Commons
Version: unspecified
Platform: Other
OS/Version: other
Status: NEW
Severity: normal
Priority: P2
Component: Pool
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: jasper_rosenberg@yahoo.com
This issue was reproduced with commons-dbcp-1.2.1 and commons-pool-1.2. It is
really a pool issue, but was easiest to demonstrate using the layer dbcp.
The exception is:
-----------------------
java.lang.NullPointerException
at
org.apache.commons.pool.impl.GenericObjectPool.addObjectToPool(GenericObjectPool.java:875)
at
org.apache.commons.pool.impl.GenericObjectPool.returnObject(GenericObjectPool.java:854)
at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:80)
at
org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:180)
at
org.quartz.utils.PoolingConnectionProviderTest.testShutdown(PoolingConnectionProviderTest.java:47)
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
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)
-----------------------
The problem is that GenericObjectPool.returnObject() asserts that the pool is
open before trying to return the connection to the pool, but
GenericObjectPool.close() nulls out the pool's fields before actually calling
the superclass BaseObjectPool.close() which is actually responsible for marking
the pool as closed.
So GenericObjectPool is in the middle of closing, having already nulled out the
underlying _pool member variable but not yet having set closed to true, when the
client tries to return an object. GenericObjectPool.returnObject() successfully
passes the assertOpen() check since closed is still set to false, but then it
blows up trying to return the connection to the underlying _pool which is null.
The following unit test demonstrates the issue:
import java.sql.Connection;
import java.sql.SQLException;
import junit.framework.TestCase;
import org.apache.commons.dbcp.BasicDataSource;
public class BasicDataSourceTest extends TestCase {
public void testShutdown() throws Exception {
final BasicDataSource datasource = new BasicDataSource();
datasource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
datasource.setUrl("jdbc:oracle:thin:@172.27.50.75:1521:devnlgv");
datasource.setUsername("dev2_shop");
datasource.setPassword("dev2_shop");
final Connection conn = datasource.getConnection();
new Thread() {
public void run() {
try {
datasource.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}.start();
conn.close();
}
}
To cause the NullPointerException, place a breakpoint at:
1. GenericObjectPool [line: 869] - addObjectToPool(Object, boolean)
2. GenericObjectPool [line: 896] - close()
Once both breakpoints are hit, let them continue and you will get the above
exception (this is with the latest dbcp and pool jars)
This issue was originally noticed in the Quartz project:
http://jira.opensymphony.com/browse/QUARTZ-289
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39052] - [pool] NullPointerException returning obj to pool during shutdown
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39052>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39052
bayard@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|NullPointerException |[pool] NullPointerException
|returning obj to pool during|returning obj to pool during
|shutdown |shutdown
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39052] - [pool] NullPointerException returning obj to pool during shutdown
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39052>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39052
sandymac@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Keywords| |FixedInTrunk
OS/Version|other |All
Platform|Other |All
Resolution| |DUPLICATE
Version|unspecified |1.2 Final
------- Additional Comments From sandymac@apache.org 2006-03-22 17:21 -------
There are two ways to view this problem.
The first is as a synchronization problem. Pool 1.3 will fix this NPE as a side
effect of other synchronization fixes that went in. 1.3 will be released soon
and you find a release candidate from:
http://people.apache.org/~sandymac/pool/1.3-rc1/ . From this point of view this
is really a dupe of Bug #37227
If you could test 1.3-rc1 and confirm that it doesn't have this problem I'd
really appreciate it.
Unfortunately this fix may still cause IllegalStateExceptions to be thrown by
returnObject after the pool has been closed. Pool 2.0 changes the behavior so
that when objects are returned to a closed pool the pool should accept those
objects and destroy them without errors. Pool 2.0 includes a number of
improvements deemed too intrusive for a long over due dot-release.
I'm marking this as a dupe of bug #37227. If you disagree or the 1.3-rc1
demonstrates the same problem please reopen this issue.
*** This bug has been marked as a duplicate of 37227 ***
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39052] - NullPointerException returning obj to pool during shutdown
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39052>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39052
------- Additional Comments From jasper_rosenberg@yahoo.com 2006-03-21 20:19 -------
Whoops, didn't mean to include the db props for my test development environments :)
Obviously, set those props to a local db to run the unit test.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39052] - [pool] NullPointerException returning obj to pool during shutdown
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39052>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39052
jasper_rosenberg@yahoo.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |VERIFIED
------- Additional Comments From jasper_rosenberg@yahoo.com 2006-03-23 19:09 -------
I just tested with 1.3-RC2 and confirmed that I not longer get a
NullPointerException, but rather an IllegalStateException as you predicted.
Though the behavior you describe as upcoming in 2.0 would obviously be ideal,
this at least gives us a predictable exception to catch and handle.
Thanks for your quick response.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39052] - [pool] NullPointerException returning obj to pool during shutdown
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39052>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39052
sandymac@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|VERIFIED |CLOSED
------- Additional Comments From sandymac@apache.org 2006-03-23 20:58 -------
If you want Pool 2 behavior now you can check out a recent nightly[1] build or
build your own from the trunk[2]. The nightly aren't well tested yet but they
have the pool 2 semantics and, except for the brand new composite pool code,
they have unit tests to verify expected pool 2 behavior.
1. http://cvs.apache.org/builds/jakarta-commons/nightly/commons-pool/
2. http://svn.apache.org/repos/asf/jakarta/commons/proper/pool/trunk/
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org