Skip to content

Commit

Permalink
Fix NPE caused by PropertyName map with Mappings names
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Nov 28, 2024
1 parent cffea0c commit 837a603
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -1231,18 +1232,13 @@ private static Map<PropertyName, String> mappingsToNames(final List<ConfigClass>
for (String name : names) {
PropertyName propertyName = new PropertyName(name);
if (propertyNames.containsKey(propertyName)) {
String existing = propertyNames.remove(propertyName);
if (existing.length() < name.length()) {
propertyNames.put(new PropertyName(existing), existing);
} else if (existing.length() > name.length()) {
propertyNames.put(propertyName, name);
} else {
if (existing.indexOf('*') <= name.indexOf('*')) {
propertyNames.put(new PropertyName(existing), existing);
} else {
propertyNames.put(propertyName, name);
}
List<String> duplicates = new ArrayList<>();
duplicates.add(name);
while (propertyNames.containsKey(propertyName)) {
duplicates.add(propertyNames.remove(propertyName));
}
String minName = Collections.min(duplicates, Comparator.comparingInt(String::length));
propertyNames.put(new PropertyName(minName), minName);
} else {
propertyNames.put(propertyName, name);
}
Expand Down

0 comments on commit 837a603

Please sign in to comment.