Skip to content

Commit afc439a

Browse files
authored
Merge pull request #2709 from tianshuang/race_condition
Fix a race condition caused by other threads calling mapper methods while mappedStatements are being constructed
2 parents 350ac91 + 7996f96 commit afc439a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/org/apache/ibatis/session/Configuration.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.Map;
2626
import java.util.Properties;
2727
import java.util.Set;
28+
import java.util.concurrent.ConcurrentHashMap;
2829
import java.util.function.BiFunction;
2930

3031
import org.apache.ibatis.binding.MapperRegistry;
@@ -998,7 +999,7 @@ protected void checkLocallyForDiscriminatedNestedResultMaps(ResultMap rm) {
998999
}
9991000
}
10001001

1001-
protected static class StrictMap<V> extends HashMap<String, V> {
1002+
protected static class StrictMap<V> extends ConcurrentHashMap<String, V> {
10021003

10031004
private static final long serialVersionUID = -4950446264854982944L;
10041005
private final String name;
@@ -1055,6 +1056,15 @@ public V put(String key, V value) {
10551056
return super.put(key, value);
10561057
}
10571058

1059+
@Override
1060+
public boolean containsKey(Object key) {
1061+
if (key == null) {
1062+
return false;
1063+
}
1064+
1065+
return super.get(key) != null;
1066+
}
1067+
10581068
@Override
10591069
public V get(Object key) {
10601070
V value = super.get(key);

0 commit comments

Comments
 (0)