Skip to content

Commit

Permalink
Merge pull request #2709 from tianshuang/race_condition
Browse files Browse the repository at this point in the history
Fix a race condition caused by other threads calling mapper methods while mappedStatements are being constructed
  • Loading branch information
harawata committed Nov 5, 2022
2 parents 350ac91 + 7996f96 commit afc439a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/org/apache/ibatis/session/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiFunction;

import org.apache.ibatis.binding.MapperRegistry;
Expand Down Expand Up @@ -998,7 +999,7 @@ protected void checkLocallyForDiscriminatedNestedResultMaps(ResultMap rm) {
}
}

protected static class StrictMap<V> extends HashMap<String, V> {
protected static class StrictMap<V> extends ConcurrentHashMap<String, V> {

private static final long serialVersionUID = -4950446264854982944L;
private final String name;
Expand Down Expand Up @@ -1055,6 +1056,15 @@ public V put(String key, V value) {
return super.put(key, value);
}

@Override
public boolean containsKey(Object key) {
if (key == null) {
return false;
}

return super.get(key) != null;
}

@Override
public V get(Object key) {
V value = super.get(key);
Expand Down

0 comments on commit afc439a

Please sign in to comment.