Skip to content

Commit

Permalink
[CONJ-1040] possible ConcurrentModificationException when connecting
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Jan 18, 2023
1 parent 22b4d2d commit 4fd57ec
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/main/java/org/mariadb/jdbc/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -617,21 +617,17 @@ private static void mapPropertiesToOption(Builder builder, Properties properties
// loop on properties,
// - check DefaultOption to check that property value correspond to type (and range)
// - set values
Properties remainingProperties = new Properties();
properties.forEach((key, val) -> remainingProperties.put(key, val));

for (Field field : Builder.class.getDeclaredFields()) {
if (remainingProperties.isEmpty()) break;
for (final Object keyObj : remainingProperties.keySet()) {
String realKey =
OptionAliases.OPTIONS_ALIASES.get(keyObj.toString().toLowerCase(Locale.ROOT));
if (realKey == null) realKey = keyObj.toString();
final Object propertyValue = remainingProperties.get(keyObj);

if (propertyValue != null && realKey != null) {
for (final Object keyObj : properties.keySet()) {
String realKey =
OptionAliases.OPTIONS_ALIASES.get(keyObj.toString().toLowerCase(Locale.ROOT));
if (realKey == null) realKey = keyObj.toString();
final Object propertyValue = properties.get(keyObj);
if (propertyValue != null && realKey != null) {
boolean used = false;
for (Field field : Builder.class.getDeclaredFields()) {
if (realKey.toLowerCase(Locale.ROOT).equals(field.getName().toLowerCase(Locale.ROOT))) {
field.setAccessible(true);
remainingProperties.remove(keyObj);
used = true;

if (field.getGenericType().equals(String.class)
&& !propertyValue.toString().isEmpty()) {
Expand Down Expand Up @@ -668,13 +664,10 @@ private static void mapPropertiesToOption(Builder builder, Properties properties
}
}
}
if (!used) nonMappedOptions.put(realKey, propertyValue);
}
}

// keep unknown option:
// those might be used in authentication or identity plugin
remainingProperties.forEach((key, val) -> nonMappedOptions.put(key, val));

// for compatibility with 2.x
if (isSet("useSsl", nonMappedOptions) || isSet("useSSL", nonMappedOptions)) {
Properties deprecatedDesc = new Properties();
Expand Down

1 comment on commit 4fd57ec

@sporadek
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this bug. We just had to change our pom.xml to use an earlier version to get a deployment done.

Please sign in to comment.