Skip to content

Commit

Permalink
[DBUTILS-137] Inefficient allocation of Maps in
Browse files Browse the repository at this point in the history
org.apache.commons.dbutils.BasicRowProcessor.toMap(ResultSet).
  • Loading branch information
garydgregory committed Dec 24, 2017
1 parent 084f286 commit 001e87d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="update" issue="DBUTILS-135" due-to="hdevalke">
BeanProcessor is not thread safe since [DBUTILS-124].
</action>
<action dev="ggregory" type="update" issue="DBUTILS-137" due-to="Gary Gregory">
Inefficient allocation of Maps in org.apache.commons.dbutils.BasicRowProcessor.toMap(ResultSet).
</action>
</release>

<release version="1.7" date="2017-07-20" description="Bug fixes and separate column &amp; property handlers using SPI">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ public <T> List<T> toBeanList(ResultSet rs, Class<? extends T> type) throws SQLE
*/
@Override
public Map<String, Object> toMap(ResultSet rs) throws SQLException {
Map<String, Object> result = new CaseInsensitiveHashMap();
ResultSetMetaData rsmd = rs.getMetaData();
int cols = rsmd.getColumnCount();
Map<String, Object> result = new CaseInsensitiveHashMap(cols);

for (int i = 1; i <= cols; i++) {
String columnName = rsmd.getColumnLabel(i);
Expand Down Expand Up @@ -188,6 +188,11 @@ public Map<String, Object> toMap(ResultSet rs) throws SQLException {
* </pre>
*/
private static class CaseInsensitiveHashMap extends LinkedHashMap<String, Object> {

private CaseInsensitiveHashMap(int initialCapacity) {
super(initialCapacity);
}

/**
* The internal mapping from lowercase keys to the real keys.
*
Expand Down

0 comments on commit 001e87d

Please sign in to comment.