Skip to content

Commit efa069f

Browse files
committed
check needed classpath for engines
1 parent 011b3f9 commit efa069f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

graphviz-java/src/main/java/guru/nidi/graphviz/engine/GraphvizCmdLineEngine.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,26 @@ public class GraphvizCmdLineEngine extends AbstractGraphvizEngine {
4848
private String outputFileName;
4949

5050
public GraphvizCmdLineEngine() {
51-
this(Optional.ofNullable(System.getenv("PATH")).orElse(""), new CommandLineExecutor());
51+
this(Optional.ofNullable(System.getenv("PATH")).orElse(""), defaultExecutor());
5252
}
5353

5454
public GraphvizCmdLineEngine(String envPath, CommandLineExecutor executor) {
5555
super(true);
56-
if (!AVAILABLE) {
57-
throw new MissingDependencyException("Command line engine is not available.",
58-
"org.apache.commons:commons-exec");
59-
}
6056
this.envPath = envPath;
6157
cmdRunner = new CommandBuilder()
6258
.withShellWrapper(true)
6359
.withCommandExecutor(executor)
6460
.build();
6561
}
6662

63+
private static CommandLineExecutor defaultExecutor() {
64+
if (!AVAILABLE) {
65+
throw new MissingDependencyException("Command line engine is not available.",
66+
"org.apache.commons:commons-exec");
67+
}
68+
return new CommandLineExecutor();
69+
}
70+
6771
@SuppressWarnings("unchecked")
6872
public GraphvizCmdLineEngine timeout(int amount, TimeUnit unit) {
6973
return super.timeout(amount, unit);

graphviz-java/src/main/java/guru/nidi/graphviz/engine/GraphvizJdkEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class GraphvizJdkEngine extends AbstractJsGraphvizEngine {
2626
public GraphvizJdkEngine() {
2727
super(false, GraphvizJdkEngine::newEngine);
2828
if (!AVAILABLE) {
29-
throw new MissingDependencyException("JDK engine is not available", "net.arnx:nashorn-promise");
29+
throw new MissingDependencyException("JDK engine is not available.", "net.arnx:nashorn-promise");
3030
}
3131
}
3232

0 commit comments

Comments
 (0)