Revision: 14959
http://sourceforge.net/p/foray/code/14959
Author: victormote
Date: 2026-08-01 16:38:54 +0000 (Sat, 01 Aug 2026)
Log Message:
-----------
Throw exception if more than one dictionary is parsed from a configured dictionary resource.
Modified Paths:
--------------
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DictionaryResource.java
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DictionaryResource.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DictionaryResource.java 2026-08-01 15:57:32 UTC (rev 14958)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DictionaryResource.java 2026-08-01 16:38:54 UTC (rev 14959)
@@ -38,6 +38,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.List;
/**
* Configuration information for a dictionary resource.
@@ -81,7 +82,14 @@
SegmentDictionary dictionary = null;
try {
final InputSource source = new InputSource(url.toExternalForm());
- dictionary = parser.parse(source).get(0);
+ final List<SegmentDictionary> dictionaries = parser.parse(source);
+ /* The parser can return more than one dictionary, but that should never happen for /configured/
+ * resources. */
+ if (dictionaries.size() > 1) {
+ throw new IllegalArgumentException("Configured dictionary resource " + url +
+ " should contain only one dictionary");
+ }
+ dictionary = dictionaries.get(0);
} catch (final IOException e) {
LoggerFactory.getLogger(this.getClass()).error("IOException", e);
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|