This is an automated email from the ASF dual-hosted git repository.

mawiesne pushed a commit to branch 
OPENNLP-1646-Remove-compiler-warnings-in-AbstractDL-and-inheriting-classes
in repository https://gitbox.apache.org/repos/asf/opennlp.git

commit 4badd9355dae803e26aad581a7dc962e3b5f722a
Author: Martin Wiesner <[email protected]>
AuthorDate: Sun Nov 17 12:16:29 2024 +0100

    OPENNLP-1646 Remove compiler warnings in AbstractDL and inheriting classes
---
 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);
     });
 
   }

Reply via email to