Skip to content

Commit

Permalink
Display initialisation error, if JEP is not initialised in the final()
Browse files Browse the repository at this point in the history
  • Loading branch information
lfoppiano committed Aug 9, 2022
1 parent eab1744 commit d74df4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Expand Up @@ -32,7 +32,7 @@ public DeLFTModel(GrobidModel model, String architecture) {
try {
LOGGER.info("Loading DeLFT model for " + model.getModelName() + " with architecture " + architecture + "...");
JEPThreadPool.getInstance().run(new InitModel(this.modelName, GrobidProperties.getInstance().getModelPath(), architecture));
} catch(InterruptedException e) {
} catch(InterruptedException | RuntimeException e) {
LOGGER.error("DeLFT model " + this.modelName + " initialization failed", e);
}
}
Expand Down
15 changes: 10 additions & 5 deletions grobid-core/src/main/java/org/grobid/core/jni/JEPThreadPool.java
Expand Up @@ -123,11 +123,16 @@ private Jep createJEPInstance() {
LOGGER.error("The JEP or DeLFT environment is not correctly installed. ", e);
throw new RuntimeException("Python/DeLFT/Jep environment not correctly installed. ", e);
} finally {
if (!success && (jep != null)) {
try {
jep.close();
} catch (JepException e) {
LOGGER.error("failed to close JEP instance", e);
if (!success) {
if (jep != null) {
try {
jep.close();
} catch (JepException e) {
LOGGER.error("failed to close JEP instance", e);
}
} else {
LOGGER.error("JEP initialisation failed somewhere.");
throw new RuntimeException("General failure in JEP. ");
}
}
}
Expand Down

0 comments on commit d74df4e

Please sign in to comment.