Bug 54225 - if initSQL property is set to an empty string a NullPointerException is thrown by DataSource#getConnection()
Summary: if initSQL property is set to an empty string a NullPointerException is throw...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-30 09:18 UTC by Jan
Modified: 2014-08-07 20:31 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan 2012-11-30 09:18:05 UTC
If the Resource in the server.xml is defined with initSQL="" the method DataSource#getConnection() throws a NullPointerException. I would suggest to change this behaviour that the part in the org.apache.tomcat.jdbc.pool.DataSourceFactory class gets changed from

>>>
value = properties.getProperty(PROP_INITSQL);
if (value != null ) {
poolProperties.setInitSQL(value);
}
<<<

to

value = properties.getProperty(PROP_INITSQL);
if (value != null && ! "".equals(value)) {
poolProperties.setInitSQL(value);
}


java.lang.NullPointerException
        at org.apache.tomcat.jdbc.pool.ConnectionPool.setupConnection(ConnectionPool.java:276)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:180)
        at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:124)
Comment 1 Filip Hanik 2014-08-07 20:31:38 UTC
Fixed in r1616592