Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CONJ-801] possible race condition correction using resultset getter …
…with label
  • Loading branch information
rusher committed Jun 22, 2020
1 parent e629ae1 commit a52752c
Showing 1 changed file with 8 additions and 6 deletions.
Expand Up @@ -86,21 +86,22 @@ public int getIndex(String name) throws SQLException {
// found, we use
// original table name.
if (aliasMap == null) {
aliasMap = new HashMap<>();
Map<String, Integer> map = new HashMap<>();
int counter = 0;
for (ColumnDefinition ci : columnInfo) {
String columnAlias = ci.getName();
if (columnAlias != null) {
columnAlias = columnAlias.toLowerCase(Locale.ROOT);
aliasMap.putIfAbsent(columnAlias, counter);
map.putIfAbsent(columnAlias, counter);

String tableName = ci.getTable();
if (tableName != null) {
aliasMap.putIfAbsent(tableName.toLowerCase(Locale.ROOT) + "." + columnAlias, counter);
map.putIfAbsent(tableName.toLowerCase(Locale.ROOT) + "." + columnAlias, counter);
}
}
counter++;
}
aliasMap = map;
}

Integer res = aliasMap.get(lowerName);
Expand All @@ -109,22 +110,23 @@ public int getIndex(String name) throws SQLException {
}

if (originalMap == null) {
originalMap = new HashMap<>();
Map<String, Integer> map = new HashMap<>();
int counter = 0;
for (ColumnDefinition ci : columnInfo) {
String columnRealName = ci.getOriginalName();
if (columnRealName != null) {
columnRealName = columnRealName.toLowerCase(Locale.ROOT);
originalMap.putIfAbsent(columnRealName, counter);
map.putIfAbsent(columnRealName, counter);

String tableName = ci.getOriginalTable();
if (tableName != null) {
originalMap.putIfAbsent(
map.putIfAbsent(
tableName.toLowerCase(Locale.ROOT) + "." + columnRealName, counter);
}
}
counter++;
}
originalMap = map;
}

res = originalMap.get(lowerName);
Expand Down

0 comments on commit a52752c

Please sign in to comment.