You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2013/10/19 22:12:39 UTC

svn commit: r1533817 - /lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/utils/SyllableUtil.java

Author: uschindler
Date: Sat Oct 19 20:12:39 2013
New Revision: 1533817

URL: http://svn.apache.org/r1533817
Log:
LUCENE-4956: Fix error handling in HanjaUtil to prevent NPE on broken classpath

Modified:
    lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/utils/SyllableUtil.java

Modified: lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/utils/SyllableUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/utils/SyllableUtil.java?rev=1533817&r1=1533816&r2=1533817&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/utils/SyllableUtil.java (original)
+++ lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/utils/SyllableUtil.java Sat Oct 19 20:12:39 2013
@@ -17,6 +17,8 @@ package org.apache.lucene.analysis.ko.ut
  * limitations under the License.
  */
 
+import java.io.BufferedInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import org.apache.lucene.analysis.ko.dic.DictionaryResources;
@@ -61,7 +63,9 @@ public class SyllableUtil {
     InputStream stream = null;
     try {
       stream = DictionaryResources.class.getResourceAsStream(DictionaryResources.FILE_SYLLABLE_DAT);
-      DataInput dat = new InputStreamDataInput(stream);
+      if (stream == null)
+        throw new FileNotFoundException(DictionaryResources.FILE_SYLLABLE_DAT);
+      DataInput dat = new InputStreamDataInput(new BufferedInputStream(stream));
       CodecUtil.checkHeader(dat, DictionaryResources.FILE_SYLLABLE_DAT, DictionaryResources.DATA_VERSION, DictionaryResources.DATA_VERSION);
       long bits[] = new long[dat.readVInt()];
       for (int i = 0; i < bits.length; i++) {