From efb9f1a8b795bb4daccbe903518d01095fc3503c Mon Sep 17 00:00:00 2001 From: reger Date: Thu, 12 May 2016 00:13:57 +0200 Subject: [PATCH 1/2] save resource for unused blacklistFiles map --- htroot/Blacklist_p.html | 2 +- source/net/yacy/repository/Blacklist.java | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/htroot/Blacklist_p.html b/htroot/Blacklist_p.html index 2f7b6691f..6c032c2a3 100644 --- a/htroot/Blacklist_p.html +++ b/htroot/Blacklist_p.html @@ -163,7 +163,7 @@
- Settings for this list + Settings for this list #[currentBlacklist]#
diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.java index f1c11cfb0..0289ab86a 100644 --- a/source/net/yacy/repository/Blacklist.java +++ b/source/net/yacy/repository/Blacklist.java @@ -39,7 +39,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.regex.Pattern; @@ -99,7 +98,6 @@ public class Blacklist { } private File blacklistRootPath = null; - private Map blacklistFiles = new TreeMap(); private final ConcurrentMap cachedUrlHashs; private final ConcurrentMap>> hostpaths_matchable; // key=host, value=path; mapped url is http://host/path; path does not start with '/' here private final ConcurrentMap>> hostpaths_notmatchable; // key=host, value=path; mapped url is http://host/path; path does not start with '/' here @@ -170,7 +168,6 @@ public class Blacklist { for (final HandleSet entry : this.cachedUrlHashs.values()) { entry.clear(); } - blacklistFiles.clear(); } public final int size() { @@ -201,9 +198,6 @@ public class Blacklist { * @param sep */ private void loadList(final BlacklistFile blFile, final String sep) { - if (!blacklistFiles.containsKey(blFile.getType())) { - blacklistFiles.put(blFile.getType(), blFile.getFileName()); - } final Map> blacklistMapMatch = getBlacklistMap(blFile.getType(), true); final Map> blacklistMapNotMatch = getBlacklistMap(blFile.getType(), false); From 4e0892962a9b5be4a9926a873712346de059c844 Mon Sep 17 00:00:00 2001 From: reger Date: Sat, 14 May 2016 03:51:13 +0200 Subject: [PATCH 2/2] fix NPE in citation servlet on empty text field --- htroot/api/citation.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htroot/api/citation.java b/htroot/api/citation.java index c5fa7aa61..4fa15286f 100644 --- a/htroot/api/citation.java +++ b/htroot/api/citation.java @@ -116,13 +116,15 @@ public class citation { ArrayList sentences = new ArrayList(); if (title != null) for (String s: title) if (s.length() > 0) sentences.add(s); - SentenceReader sr = new SentenceReader(text); - StringBuilder line; - while (sr.hasNext()) { - line = sr.next(); - if (line.length() > 0) sentences.add(line.toString()); + if (text != null && !text.isEmpty()) { + SentenceReader sr = new SentenceReader(text); + StringBuilder line; + while (sr.hasNext()) { + line = sr.next(); + if (line.length() > 0) sentences.add(line.toString()); + } } - + // for each line make a statistic about the number of occurrences somewhere else OrderedScoreMap scores = new OrderedScoreMap(null); // accumulates scores for citating urls LinkedHashMap> sentenceOcc = new LinkedHashMap>();