fix NPE in snippet computation

pull/1/head
reger 10 years ago
parent 49281617d2
commit e48720a58c

@ -166,7 +166,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
final ResultClass source = ResultClass.SOURCE_CACHE; final ResultClass source = ResultClass.SOURCE_CACHE;
final String wordhashes = RemoteSearch.set2string(queryhashes); final String wordhashes = RemoteSearch.set2string(queryhashes);
final String urls = ASCII.String(url.hash()); final String urls = ASCII.String(url.hash());
String snippetLine = snippetsCache.get(wordhashes, urls); final String snippetLine = snippetsCache.get(wordhashes, urls);
if (snippetLine != null) { if (snippetLine != null) {
// found the snippet // found the snippet
init(url.hash(), snippetLine, false, source, null); init(url.hash(), snippetLine, false, source, null);
@ -336,11 +336,11 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
init(url.hash(), null, false, ResultClass.ERROR_NO_MATCH, "no matching snippet found"); init(url.hash(), null, false, ResultClass.ERROR_NO_MATCH, "no matching snippet found");
return; return;
} }
if (snippetLine.length() > snippetMaxLength) snippetLine = snippetLine.substring(0, snippetMaxLength); if (textline.length() > snippetMaxLength) textline = textline.substring(0, snippetMaxLength);
// finally store this snippet in our own cache // finally store this snippet in our own cache
snippetsCache.put(wordhashes, urls, textline); snippetsCache.put(wordhashes, urls, textline);
init(url.hash(), snippetLine, false, source, null); init(url.hash(), textline, false, source, null);
} }
private void init( private void init(

Loading…
Cancel
Save