Skip to content

Commit da0f8c9

Browse files
committed
Shared ambiguity instance
1 parent 7ae38a2 commit da0f8c9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ public V put(String key, V value) {
11551155
if (super.get(shortKey) == null) {
11561156
super.put(shortKey, value);
11571157
} else {
1158-
super.put(shortKey, (V) new Ambiguity(shortKey));
1158+
super.put(shortKey, (V) Ambiguity.INSTANCE);
11591159
}
11601160
}
11611161
return super.put(key, value);
@@ -1177,13 +1177,16 @@ public V get(Object key) {
11771177
throw new IllegalArgumentException(name + " does not contain value for " + key);
11781178
}
11791179
if (value instanceof Ambiguity) {
1180-
throw new IllegalArgumentException(((Ambiguity) value).getSubject() + " is ambiguous in " + name
1180+
throw new IllegalArgumentException(key + " is ambiguous in " + name
11811181
+ " (try using the full name including the namespace, or rename one of the entries)");
11821182
}
11831183
return value;
11841184
}
11851185

11861186
protected static class Ambiguity {
1187+
1188+
protected static Ambiguity INSTANCE = new Ambiguity("ambiguity");
1189+
11871190
private final String subject;
11881191

11891192
public Ambiguity(String subject) {

0 commit comments

Comments
 (0)