[
https://issues.apache.org/jira/browse/OPENNLP-1646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17898988#comment-17898988
]
ASF GitHub Bot commented on OPENNLP-1646:
-----------------------------------------
mawiesne commented on code in PR #688:
URL: https://github.com/apache/opennlp/pull/688#discussion_r1845422349
##########
opennlp-dl/src/test/java/opennlp/dl/namefinder/NameFinderDLEval.java:
##########
@@ -200,10 +200,8 @@ public void invalidModel() {
final File model = new File("invalid.onnx");
final File vocab = new File("vocab.txt");
-
- try (final NameFinderDL nameFinderDL = new NameFinderDL(model, vocab,
getIds2Labels(),
- sentenceDetector)) {
- }
+ //noinspection resource
+ new NameFinderDL(model, vocab, getIds2Labels(), sentenceDetector);
Review Comment:
Compiler warning was similar than in issue description, related to close
method call, via try...
> Remove compiler warnings in AbstractDL and inheriting classes
> -------------------------------------------------------------
>
> Key: OPENNLP-1646
> URL: https://issues.apache.org/jira/browse/OPENNLP-1646
> Project: OpenNLP
> Issue Type: Improvement
> Components: Deep Learning
> Affects Versions: 2.5.0
> Reporter: Martin Wiesner
> Assignee: Martin Wiesner
> Priority: Trivial
> Fix For: 2.5.1
>
>
> Starting with OPENNLP-1618, AbstractDL implements {{AutoClosable}}. However,
> the {{close}} method allows to throw any type inheriting from Exception.
> This, however, leads to a bunch of compiler warnings being issued:
> {{AbstractDL.java:[37,17] auto-closeable resource opennlp.dl.AbstractDL has a
> member method close() that could throw InterruptedException}}
> {{...}}
> during compilation, for all classes that inherit from or use {{AbstractDL}}.
> +The fix is simple+:
> Override the {{throws Exception}} declaration with more specific exceptions,
> for instance: {{throws OrtException, IllegalStateException}} that can be
> thrown in this case. Thus, {{InterruptedException}} is not declared /
> possible and *javac* is happy again.
> Let's cure this.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)