This is an automated email from the ASF dual-hosted git repository.
mawiesne pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opennlp.git
The following commit(s) were added to refs/heads/main by this push:
new 4d9dab9c OPENNLP-1646: Remove compiler warnings in AbstractDL and
inheriting classes (#688)
4d9dab9c is described below
commit 4d9dab9cbff129108e08a1ca9cceeff36215a6a2
Author: Martin Wiesner <[email protected]>
AuthorDate: Sun Nov 17 12:57:14 2024 +0100
OPENNLP-1646: Remove compiler warnings in AbstractDL and inheriting classes
(#688)
---
opennlp-dl/src/main/java/opennlp/dl/AbstractDL.java | 6 ++++--
.../src/test/java/opennlp/dl/namefinder/NameFinderDLEval.java | 6 ++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/opennlp-dl/src/main/java/opennlp/dl/AbstractDL.java
b/opennlp-dl/src/main/java/opennlp/dl/AbstractDL.java
index b1b0bf67..eb8c41ce 100644
--- a/opennlp-dl/src/main/java/opennlp/dl/AbstractDL.java
+++ b/opennlp-dl/src/main/java/opennlp/dl/AbstractDL.java
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
import ai.onnxruntime.OrtEnvironment;
+import ai.onnxruntime.OrtException;
import ai.onnxruntime.OrtSession;
import opennlp.tools.tokenize.Tokenizer;
@@ -68,10 +69,11 @@ public abstract class AbstractDL implements AutoCloseable {
/**
* Closes this resource, relinquishing any underlying resources.
*
- * @throws Exception If it failed to close.
+ * @throws OrtException Thrown if it failed to close Ort resources.
+ * @throws IllegalStateException Thrown if the underlying resources were
already closed.
*/
@Override
- public void close() throws Exception {
+ public void close() throws OrtException, IllegalStateException {
if (session != null) {
session.close();
}
diff --git
a/opennlp-dl/src/test/java/opennlp/dl/namefinder/NameFinderDLEval.java
b/opennlp-dl/src/test/java/opennlp/dl/namefinder/NameFinderDLEval.java
index f8febbd0..779da33f 100644
--- a/opennlp-dl/src/test/java/opennlp/dl/namefinder/NameFinderDLEval.java
+++ b/opennlp-dl/src/test/java/opennlp/dl/namefinder/NameFinderDLEval.java
@@ -200,10 +200,8 @@ public class NameFinderDLEval extends AbstractDLTest {
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);
});
}