From 4589afe056e3a95d91249e83c5a045b58588ef55 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Thu, 24 Jan 2013 14:12:31 +0100 Subject: [PATCH] fix NPE when solr does not deliver snippets --- source/net/yacy/peers/Protocol.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.java index 65735d010..be26d99ae 100644 --- a/source/net/yacy/peers/Protocol.java +++ b/source/net/yacy/peers/Protocol.java @@ -1104,18 +1104,20 @@ public final class Protocol // evaluate snippets Map>> rawsnippets = rsp.getHighlighting(); // a map from the urlhash to a map with key=field and value = list of snippets Map snippets = new HashMap(); // this will be a list of urlhash-snippet entries - nextsnippet: for (Map.Entry>> re: rawsnippets.entrySet()) { - Map> rs = re.getValue(); - for (YaCySchema field: snippetFields) { - if (rs.containsKey(field.getSolrFieldName())) { - List s = rs.get(field.getSolrFieldName()); - if (s.size() > 0) { - snippets.put(re.getKey(), s.get(0)); - continue nextsnippet; + if (rawsnippets != null) { + nextsnippet: for (Map.Entry>> re: rawsnippets.entrySet()) { + Map> rs = re.getValue(); + for (YaCySchema field: snippetFields) { + if (rs.containsKey(field.getSolrFieldName())) { + List s = rs.get(field.getSolrFieldName()); + if (s.size() > 0) { + snippets.put(re.getKey(), s.get(0)); + continue nextsnippet; + } } } + // no snippet found :( --we don't assign a value here by default; that can be done as an evaluation outside this method } - // no snippet found :( --we don't assign a value here by default; that can be done as an evaluation outside this method } // evaluate result