Skip to content

Commit

Permalink
Shared ambiguity instance
Browse files Browse the repository at this point in the history
  • Loading branch information
nieqiurong committed Apr 18, 2024
1 parent 7ae38a2 commit da0f8c9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/org/apache/ibatis/session/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ public V put(String key, V value) {
if (super.get(shortKey) == null) {
super.put(shortKey, value);
} else {
super.put(shortKey, (V) new Ambiguity(shortKey));
super.put(shortKey, (V) Ambiguity.INSTANCE);
}
}
return super.put(key, value);
Expand All @@ -1177,13 +1177,16 @@ public V get(Object key) {
throw new IllegalArgumentException(name + " does not contain value for " + key);
}
if (value instanceof Ambiguity) {
throw new IllegalArgumentException(((Ambiguity) value).getSubject() + " is ambiguous in " + name
throw new IllegalArgumentException(key + " is ambiguous in " + name
+ " (try using the full name including the namespace, or rename one of the entries)");
}
return value;
}

protected static class Ambiguity {

protected static Ambiguity INSTANCE = new Ambiguity("ambiguity");

private final String subject;

public Ambiguity(String subject) {
Expand Down

0 comments on commit da0f8c9

Please sign in to comment.