mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-22 04:55:10 +00:00
refactor: remove dead code
This commit is contained in:
parent
171a35971b
commit
91e87b9691
@ -113,7 +113,7 @@ public class OptionFlags {
|
|||||||
systemExit = exit;
|
systemExit = exit;
|
||||||
gui = false;
|
gui = false;
|
||||||
quiet = false;
|
quiet = false;
|
||||||
checkDotError = false;
|
// checkDotError = false;
|
||||||
printFonts = false;
|
printFonts = false;
|
||||||
// failOnError = false;
|
// failOnError = false;
|
||||||
encodesprite = false;
|
encodesprite = false;
|
||||||
@ -130,7 +130,7 @@ public class OptionFlags {
|
|||||||
private boolean systemExit;
|
private boolean systemExit;
|
||||||
private boolean gui;
|
private boolean gui;
|
||||||
private boolean quiet;
|
private boolean quiet;
|
||||||
private boolean checkDotError;
|
// private boolean checkDotError;
|
||||||
private boolean printFonts;
|
private boolean printFonts;
|
||||||
private boolean encodesprite;
|
private boolean encodesprite;
|
||||||
private boolean dumpHtmlStats;
|
private boolean dumpHtmlStats;
|
||||||
@ -195,12 +195,12 @@ public class OptionFlags {
|
|||||||
this.quiet = quiet;
|
this.quiet = quiet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isCheckDotError() {
|
// public final boolean isCheckDotError() {
|
||||||
return checkDotError;
|
// return checkDotError;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final void setCheckDotError(boolean checkDotError) {
|
public final void setCheckDotError(boolean checkDotError) {
|
||||||
this.checkDotError = checkDotError;
|
// this.checkDotError = checkDotError;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final AtomicBoolean logDataInitized = new AtomicBoolean(false);
|
private final AtomicBoolean logDataInitized = new AtomicBoolean(false);
|
||||||
|
@ -121,18 +121,17 @@ abstract class AbstractGraphviz implements Graphviz {
|
|||||||
} finally {
|
} finally {
|
||||||
Log.info("Ending Graphviz process");
|
Log.info("Ending Graphviz process");
|
||||||
}
|
}
|
||||||
if (OptionFlags.getInstance().isCheckDotError() && p != null && p.getError().length() > 0) {
|
// if (OptionFlags.getInstance().isCheckDotError() && p != null && p.getError().length() > 0) {
|
||||||
Log.error("GraphViz error stream : " + p.getError());
|
// Log.error("GraphViz error stream : " + p.getError());
|
||||||
if (OptionFlags.getInstance().isCheckDotError())
|
// if (OptionFlags.getInstance().isCheckDotError())
|
||||||
throw new IllegalStateException("Dot error " + p.getError());
|
// throw new IllegalStateException("Dot error " + p.getError());
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
if (OptionFlags.getInstance().isCheckDotError() && p != null && p.getOut().length() > 0) {
|
// if (OptionFlags.getInstance().isCheckDotError() && p != null && p.getOut().length() > 0) {
|
||||||
Log.error("GraphViz out stream : " + p.getOut());
|
// Log.error("GraphViz out stream : " + p.getOut());
|
||||||
if (OptionFlags.getInstance().isCheckDotError())
|
// if (OptionFlags.getInstance().isCheckDotError())
|
||||||
throw new IllegalStateException("Dot out " + p.getOut());
|
// throw new IllegalStateException("Dot out " + p.getOut());
|
||||||
|
// }
|
||||||
}
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
package net.sourceforge.plantuml.dot;
|
package net.sourceforge.plantuml.dot;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -49,8 +48,8 @@ public class ProcessRunner {
|
|||||||
// ::remove file when __CORE__
|
// ::remove file when __CORE__
|
||||||
|
|
||||||
private final String[] cmd;
|
private final String[] cmd;
|
||||||
private String error = "";
|
private String error;
|
||||||
private String out = "";
|
private String out;
|
||||||
|
|
||||||
public ProcessRunner(String[] cmd) {
|
public ProcessRunner(String[] cmd) {
|
||||||
this.cmd = cmd;
|
this.cmd = cmd;
|
||||||
@ -61,14 +60,14 @@ public class ProcessRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ProcessState run(byte[] in, OutputStream redirection, SFile dir) {
|
public ProcessState run(byte[] in, OutputStream redirection, SFile dir) {
|
||||||
|
Process process = null;
|
||||||
try {
|
try {
|
||||||
final ProcessBuilder builder = new ProcessBuilder(cmd);
|
final ProcessBuilder builder = new ProcessBuilder(cmd);
|
||||||
if (dir != null)
|
if (dir != null)
|
||||||
builder.directory(dir.conv());
|
builder.directory(dir.conv());
|
||||||
|
|
||||||
builder.redirectErrorStream(true);
|
builder.redirectErrorStream(true);
|
||||||
|
|
||||||
final Process process = builder.start();
|
process = builder.start();
|
||||||
|
|
||||||
// Handling input to the process
|
// Handling input to the process
|
||||||
if (in != null)
|
if (in != null)
|
||||||
@ -96,20 +95,30 @@ public class ProcessRunner {
|
|||||||
return ProcessState.TERMINATED_OK();
|
return ProcessState.TERMINATED_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process did not finish in time, kill it
|
|
||||||
process.destroy();
|
|
||||||
this.error = "Timeout - kill";
|
|
||||||
if (process.waitFor(500, TimeUnit.MILLISECONDS) == false) {
|
|
||||||
process.destroyForcibly();
|
|
||||||
this.error = "Timeout - kill force";
|
|
||||||
}
|
|
||||||
|
|
||||||
return ProcessState.TIMEOUT();
|
return ProcessState.TIMEOUT();
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
this.error = e.toString();
|
this.error = e.toString();
|
||||||
return ProcessState.EXCEPTION(e);
|
return ProcessState.EXCEPTION(e);
|
||||||
|
} finally {
|
||||||
|
if (process != null && out == null && process.isAlive()) {
|
||||||
|
// Process did not finish in time, kill it
|
||||||
|
process.destroy();
|
||||||
|
// Not really sure that we should overwrite "this.error" here
|
||||||
|
this.error = "Timeout - kill";
|
||||||
|
try {
|
||||||
|
if (process.waitFor(500, TimeUnit.MILLISECONDS) == false) {
|
||||||
|
process.destroyForcibly();
|
||||||
|
this.error = "Timeout - kill force";
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Nothing we can really do
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user