Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two collection properties for DBCP 2 trigger NPE in CommonDataSourceDatabase.createDataSource() #95

Open
justincranford opened this issue Jul 18, 2015 · 1 comment

Comments

@justincranford
Copy link

I am upgrading Commons DBCP 1.4.0 to 2.1.0 in my web app. I tested HA-JDBC 3.0.4-SNAPSHOT compatibility with DBCP 2 and it works. However, I ran into a configuration issue for two specific properties in DBCP 2: "connectionInitSqls" and "disconnectionSqlCodes". DBCP 2 configuration docs say they are strings representing collections with elements separated by semi-colons, but the getters/setters in BasicDataSource.java are collection objects instead of String.

I reproduced it by using DataSourceDatabase to configure HA-JDBC. I set location "org.apache.commons.dbcp2.BasicDataSource", and I set my properties for HA-JDBC to pass to each instantiated BasicDataSource object. During initialization, CommonDataSourceDatabase.createDataSource() throws a NullPointerException at line 136.

134: PropertyEditor editor = PropertyEditorManager.findEditor(descriptor.getPropertyType());
136: editor.setAsText(value);

I debugged and found descriptor.getPropertyType() returns List and Set, respectively. Passing either of those values to findEditor() returns NULL on line 134, hence the NPE on line 136.

Everything else in BasicDataSource seems to work with HA-JDBC 3.0.4-SNAPSHOT. DBCP 2.1 relies on Commons Pool 2.4.0, but there is no conflict with HA-JDBC depending on Commons Pool 1.6.0 because of different package names. I am not using these two properties, so this does not block me. I just wanted to report it in case anyone else runs into it using DBCP 2 with HA-JDBC 3.0 and those two properties.

@pferraro
Copy link
Member

Thanks for pointing this out. We should be able to handle this via a custom PropertyEditor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants