brettwooldridge / HikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Apache License 2.0
19.91k stars 2.92k forks source link

char[] password for Driver-based configurations #2021

Open cquezel opened 1 year ago

cquezel commented 1 year ago

I'm pretty sure this is not a bug but a feature request but here it goes:

I just updated the JDBC driver I was using and the connexion pool configuration started failling. The problem is that my JDBC driver's setPassword method now has this signature:

void com.ibm.as400.access.AS400JDBCDataSource.setPassword(char[])

Notice "not a String."

In the PropertyElf.setProperty method, there is an if to branch to the various types of parameters (int, long, short, boolean, String). char[] could be added to the list. :)

There is a discussion on stackoverflow on why char[] is better than String for password: https://stackoverflow.com/questions/8881291/why-is-char-preferred-over-string-for-passwords

legrottagliegionata commented 1 year ago

Hi, I propose to use one more condition to select the correct method to invoke. This could be an example. var writeMethod = methods.stream().filter(m -> m.getName().equals(methodName) && m.getParameterCount() == 1 && m.getParameterTypes()[0].equals(paramValue.getClass())).findFirst().orElse(null);

in my case the AS400JDBCDataSource class has two setPassword methods, one with char[] and the other String, in this way we should be able to use the right method

m1h43l commented 4 months ago

This has been fixed in 5.1.0. This ticket can be closed.