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) { private static void addUniqueQuerySet(Collection<String> terms, Function<String, String> keyFunction, Function<String, String> valueFunction, Map<String, String> uniqueMap) {
for (String it : terms) { for (String term : terms) {
String key = keyFunction.apply(it); if (term != null && term.length() > 0) {
if (key.length() > 0 && !uniqueMap.containsKey(key)) { String key = keyFunction.apply(term);
uniqueMap.put(key, valueFunction.apply(it)); if (key != null && key.length() > 0 && !uniqueMap.containsKey(key)) {
uniqueMap.put(key, valueFunction.apply(term));
}
} }
} }
} }