Skip to content

Commit adce996

Browse files
committed
avoid loading incorrect engines
1 parent 0044b31 commit adce996

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/io/bioimage/modelrunner/tensorflow/v2/api050/Tensorflow2Interface.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import java.nio.charset.StandardCharsets;
5555
import java.nio.file.Files;
5656
import java.nio.file.Paths;
57-
import java.security.CodeSource;
5857
import java.security.ProtectionDomain;
5958
import java.time.LocalDateTime;
6059
import java.time.format.DateTimeFormatter;
@@ -146,6 +145,10 @@ public class Tensorflow2Interface implements DeepLearningEngineInterface {
146145
* File extension for the temporal files used for interprocessing
147146
*/
148147
final private static String FILE_EXTENSION = ".dat";
148+
/**
149+
* Name without vesion of the JAR created for this library
150+
*/
151+
private static final String JAR_FILE_NAME = "dl-modelrunner-tensorflow-";
149152

150153
/**
151154
* The loaded Tensorflow 2 model
@@ -675,6 +678,8 @@ private List<String> getProcessCommandsWithoutArgs() throws IOException, URISynt
675678
String codeSource = protectionDomain.getCodeSource().getLocation().getPath();
676679
String f_name = URLDecoder.decode(codeSource, StandardCharsets.UTF_8.toString());
677680
for (File ff : new File(f_name).getParentFile().listFiles()) {
681+
if (ff.getName().startsWith(JAR_FILE_NAME) && !ff.getAbsolutePath().equals(f_name))
682+
continue;
678683
classpath += ff.getAbsolutePath() + File.pathSeparator;
679684
}
680685
String className = Tensorflow2Interface.class.getName();

0 commit comments

Comments
 (0)