vibur / vibur-dbcp

Vibur DBCP - concurrent and dynamic JDBC connection pool
http://www.vibur.org
Apache License 2.0
96 stars 11 forks source link

Crashes occur when inputs are not integers #13

Closed Reed-Stratix closed 4 years ago

Reed-Stratix commented 4 years ago

From vibur-dbcp/src/main/java/org/vibur/dbcp/util/ViburUtils.java

public static String formatSql(String sqlQuery, List<Object[]> sqlQueryParams) {
    StringBuilder result = new StringBuilder(1024).append("-- ").append(sqlQuery);

    if (sqlQueryParams != null && !sqlQueryParams.isEmpty()) {
        Object[] params = sqlQueryParams.toArray();
        Arrays.sort(params, new Comparator<Object>() {
            @Override
            public int compare(Object o1, Object o2) {
                return Integer.compare((int) ((Object[]) o1)[1], (int) ((Object[]) o2)[1]);
            }
        });

        result.append("\n-- Parameters:\n-- ").append(Arrays.deepToString(params));
    }
    return result.toString();
}

Causes crashes when the input values are not integers.

simeonmalchev commented 4 years ago

Thanks for opening this issue. The fix is straightforward but may take me a couple of weeks before I'm able to push a new release up to maven central. Please disable the queries params logging in the meantime.

simeonmalchev commented 4 years ago

Fixed in version 24.0.