Skip to content

Commit

Permalink
Optimize the code in TypeAliasRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
kang-hl committed Mar 13, 2023
1 parent e68216b commit fb2a6e9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/org/apache/ibatis/type/TypeAliasRegistry.java
Expand Up @@ -161,11 +161,14 @@ public void registerAlias(String alias, Class<?> value) {
}
// issue #748
String key = alias.toLowerCase(Locale.ENGLISH);
if (typeAliases.containsKey(key) && typeAliases.get(key) != null && !typeAliases.get(key).equals(value)) {
throw new TypeException(
"The alias '" + alias + "' is already mapped to the value '" + typeAliases.get(key).getName() + "'.");
Class<?> cls = typeAliases.get(key);
if (cls != null) {
if (!cls.equals(value)) {
throw new TypeException("The alias '" + alias + "' is already mapped to the value '" + cls.getName() + "'.");
}
} else {
typeAliases.put(key, value);
}
typeAliases.put(key, value);
}

public void registerAlias(String alias, String value) {
Expand Down

0 comments on commit fb2a6e9

Please sign in to comment.