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

Optimize the code in TypeAliasRegistry #2842

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
11 changes: 7 additions & 4 deletions src/main/java/org/apache/ibatis/type/TypeAliasRegistry.java
Original file line number Diff line number Diff line change
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