From 4e0892962a9b5be4a9926a873712346de059c844 Mon Sep 17 00:00:00 2001 From: reger Date: Sat, 14 May 2016 03:51:13 +0200 Subject: [PATCH] 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>();