Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a race condition caused by other threads calling mapper methods while mappedStatements are being constructed #2709

Merged
merged 2 commits into from
Nov 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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