From 60b62890d1e814916feea8f572c796cbb041648a Mon Sep 17 00:00:00 2001 From: Frank Liu Date: Sun, 30 May 2021 09:46:27 -0700 Subject: [PATCH] [api] Fix saveModel NPE bug Change-Id: I288d6ca80a7e987f2e527e18f020fee0f75d8156 --- api/src/main/java/ai/djl/BaseModel.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/src/main/java/ai/djl/BaseModel.java b/api/src/main/java/ai/djl/BaseModel.java index ecb39c104dc..4b2478d9a80 100644 --- a/api/src/main/java/ai/djl/BaseModel.java +++ b/api/src/main/java/ai/djl/BaseModel.java @@ -228,6 +228,9 @@ protected Block loadFromBlockFactory() { /** {@inheritDoc} */ @Override public void save(Path modelPath, String newModelName) throws IOException { + if (newModelName == null || newModelName.isEmpty()) { + newModelName = modelName; + } if (Files.notExists(modelPath)) { Files.createDirectories(modelPath); }