Copilot commented on code in PR #975:
URL: https://github.com/apache/opennlp/pull/975#discussion_r2936693872
##########
README.md:
##########
@@ -141,8 +141,10 @@ To support ongoing development and stable maintenance of
Apache OpenNLP, the pro
### Branch overview
-- **`main`**: Development branch for version **3.0** and beyond. All feature
development and 3.x releases occur here.
-- **`opennlp-2.x`**: Maintains the stable **2.x** release line. This branch
will receive selective updates and patch releases.
+- **`main`**: Development branch for version **3.0** and beyond.
+ All feature development and 3.x releases occur here. Minimum
Java level: 21.
+- **`opennlp-2.x`**: Maintains the stable **2.x** release line.
+ This branch will receive selective updates and patch releases.
Minimum Java level: 17.
Review Comment:
The wrapped lines under the branch list items are indented enough to be
rendered as a code block in Markdown (4+ spaces inside a list item). This
likely makes the “All feature development…” / “This branch will…” lines display
monospaced and separate from the bullet text. Reduce indentation (e.g., 2
spaces) or keep the content on one line to preserve normal list formatting.
##########
opennlp-extensions/opennlp-uima/src/main/java/opennlp/uima/normalizer/NumberUtil.java:
##########
@@ -36,7 +36,7 @@ public final class NumberUtil {
* @return true if the language is supported
*/
public static boolean isLanguageSupported(String languageCode) {
- Locale locale = new Locale(languageCode);
+ Locale locale = Locale.of(languageCode);
Locale[] possibleLocales = NumberFormat.getAvailableLocales();
Review Comment:
`Locale.of(languageCode)` can throw `IllformedLocaleException` for
malformed/unsupported tags. That would make `isLanguageSupported` unexpectedly
throw at runtime instead of returning `false`, changing the method’s behavior
for bad input. Consider catching `IllformedLocaleException` and returning
`false` (or normalizing via `Locale.forLanguageTag`), so callers don’t have to
handle an unchecked exception.
##########
opennlp-extensions/opennlp-uima/src/main/java/opennlp/uima/normalizer/NumberUtil.java:
##########
@@ -70,7 +70,7 @@ public static Number parse(String number, String languageCode)
throw new IllegalArgumentException("Language " + languageCode + " is not
supported!");
}
- Locale locale = new Locale(languageCode);
+ Locale locale = Locale.of(languageCode);
NumberFormat numberFormat = NumberFormat.getInstance(locale);
number = WHITESPACE_PATTERN.matcher(number).replaceAll("");
Review Comment:
`parse()` calls `Locale.of(languageCode)` again after the support check.
Even if `isLanguageSupported` is updated to handle malformed tags gracefully,
this second call can still throw `IllformedLocaleException` and bypass the
documented `IllegalArgumentException` path. Recommend reusing the validated
`Locale` from the support check, or catching `IllformedLocaleException` here
and translating it into the expected `IllegalArgumentException`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]