diff --git a/enhancement-engines/entitylinking/labeltokenizer-lucene/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/labeltokenizer/lucene/LuceneLabelTokenizer.java b/enhancement-engines/entitylinking/labeltokenizer-lucene/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/labeltokenizer/lucene/LuceneLabelTokenizer.java index b91ca70b3..cbfa6ed1e 100644 --- a/enhancement-engines/entitylinking/labeltokenizer-lucene/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/labeltokenizer/lucene/LuceneLabelTokenizer.java +++ b/enhancement-engines/entitylinking/labeltokenizer-lucene/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/labeltokenizer/lucene/LuceneLabelTokenizer.java @@ -206,10 +206,19 @@ public String[] tokenize(String label, String language) { tokens.add(label.substring(offset.startOffset(), offset.endOffset())); } tokenizer.end(); - tokenizer.close(); } catch (IOException e) { log.error("IOException while reading from a StringReader :(",e); return null; + } finally { + try { + if (tokenizer == null) { + return null; + } + tokenizer.close(); + } catch (IOException e) { + log.error("IOException while closing a StringReader :(",e); + return null; + } } return tokens.toArray(new String[tokens.size()]); } else {