ASF Bugzilla – Attachment 36824 Details for
Bug 63833
NPE in DBCP when attempting to connect to a database that doesn't exist
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
A new draft patch for review.
BZ-63833-2.patch (text/plain), 2.47 KB, created by
Guoxiong Li
on 2019-10-12 07:03:04 UTC
(
hide
)
Description:
A new draft patch for review.
Filename:
MIME Type:
Creator:
Guoxiong Li
Created:
2019-10-12 07:03:04 UTC
Size:
2.47 KB
patch
obsolete
>diff --git a/java/org/apache/tomcat/dbcp/dbcp/PoolableConnectionFactory.java b/java/org/apache/tomcat/dbcp/dbcp/PoolableConnectionFactory.java >index b04fa6f412..af7126141e 100644 >--- a/java/org/apache/tomcat/dbcp/dbcp/PoolableConnectionFactory.java >+++ b/java/org/apache/tomcat/dbcp/dbcp/PoolableConnectionFactory.java >@@ -640,7 +640,9 @@ public class PoolableConnectionFactory implements PoolableObjectFactory<Poolable > > @Override > public void destroyObject(PoolableConnection obj) throws Exception { >- obj.reallyClose(); >+ if (obj != null) { >+ obj.reallyClose(); >+ } > } > > @Override >diff --git a/test/org/apache/tomcat/dbcp/dbcp/TestPoolableConnectionFactory.java b/test/org/apache/tomcat/dbcp/dbcp/TestPoolableConnectionFactory.java >new file mode 100644 >index 0000000000..689c3724cf >--- /dev/null >+++ b/test/org/apache/tomcat/dbcp/dbcp/TestPoolableConnectionFactory.java >@@ -0,0 +1,39 @@ >+/* >+ * Licensed to the Apache Software Foundation (ASF) under one or more >+ * contributor license agreements. See the NOTICE file distributed with >+ * this work for additional information regarding copyright ownership. >+ * The ASF licenses this file to You under the Apache License, Version 2.0 >+ * (the "License"); you may not use this file except in compliance with >+ * the License. You may obtain a copy of the License at >+ * >+ * http://www.apache.org/licenses/LICENSE-2.0 >+ * >+ * Unless required by applicable law or agreed to in writing, software >+ * distributed under the License is distributed on an "AS IS" BASIS, >+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >+ * See the License for the specific language governing permissions and >+ * limitations under the License. >+ */ >+package org.apache.tomcat.dbcp.dbcp; >+ >+import org.apache.tomcat.dbcp.pool.impl.GenericObjectPool; >+import org.junit.Assert; >+import org.junit.Test; >+ >+/** >+ * General tests for PoolableConnectionFactory >+ */ >+public class TestPoolableConnectionFactory { >+ @Test >+ public void testDestroyObject() { >+ // test null pointer exception >+ PoolableConnectionFactory factory = new PoolableConnectionFactory(null, new GenericObjectPool(), null, null, false, false); >+ try { >+ factory.destroyObject(null); >+ } catch (NullPointerException npe) { >+ Assert.fail("The destroyObject method in PoolableConnectionFactory throws a NullPointerException"); >+ } catch (Exception e) { >+ // NOOP >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 63833
:
36823
| 36824