Fix potential NPE

@see https://www.filebot.net/forums/viewtopic.php?f=6&t=4234&p=23851#p23851
This commit is contained in:
Reinhard Pointner 2016-10-17 02:37:36 +08:00
parent d7215de8c5
commit 23542c58c5
1 changed files with 6 additions and 4 deletions

View File

@ -966,10 +966,12 @@ public class MediaDetection {
}
private static void addUniqueQuerySet(Collection<String> terms, Function<String, String> keyFunction, Function<String, String> valueFunction, Map<String, String> uniqueMap) {
for (String it : terms) {
String key = keyFunction.apply(it);
if (key.length() > 0 && !uniqueMap.containsKey(key)) {
uniqueMap.put(key, valueFunction.apply(it));
for (String term : terms) {
if (term != null && term.length() > 0) {
String key = keyFunction.apply(term);
if (key != null && key.length() > 0 && !uniqueMap.containsKey(key)) {
uniqueMap.put(key, valueFunction.apply(term));
}
}
}
}