nidi3 / graphviz-java

Use graphviz with pure java
Apache License 2.0
937 stars 107 forks source link

Default GraphvizServerEngine is useless #150

Closed Clashsoft closed 4 years ago

Clashsoft commented 4 years ago

The default engines always contains a GraphvizServerEngine instance:

https://github.com/nidi3/graphviz-java/blob/efa069f764046117f92c84fedac82bcd00f23d35/graphviz-java/src/main/java/guru/nidi/graphviz/engine/Graphviz.java#L80

However, as GraphvizServerEngine#useEngine is not called by default, it's internal engines list is empty. Because of this, it always errors with a timeout exception. This only happens if neither V8 nor Dot is available. The Jdk engine is never reached unless explicitly specified with Graphviz.useEngine(new GraphvizJdkEngine()).

nidi3 commented 4 years ago

There's no timeout when there's already a GraphvizServer running. This is the idea behind the Server Engine: keep a process running to avoid initialization cost. But it's probably a special case which is better not in the default engines list.