package droplauncher.util;

import adakite.debugging.Debugging;
import adakite.util.AdakiteUtils;
import java.io.IOException;
import java.nio.file.Path;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * Container class for starting and stopping a new process.
 */
public class CustomProcess {

  private static final Logger LOGGER = LogManager.getLogger();

  private Process process;
  private String[] args;
  private Path cwd;
  private StreamGobbler gobblerStdout;
  private StreamGobbler gobblerStderr;

  public CustomProcess() {
    this.process = null;
    this.args = null;
    this.cwd = null;
    this.gobblerStdout = null;
    this.gobblerStderr = null;
  }

  /**
   * Returns the current working directory for the process.
   */
  public Path getCWD() {
    return this.cwd;
  }

  /**
   * Sets the current working directory for the executable.
   *
   * @param path specified current working directory
   */
  public void setCWD(Path path) {
    this.cwd = path;
  }

  /**
   * Creates and opens the pipe to the specified executable.
   *
   * @param args specified command and arguments to run
   * @throws IOException
   */
  public void open(String[] args) throws IOException {
    if (args == null) {
      throw new IllegalArgumentException(Debugging.nullObject("args"));
    }

    this.args = args;

    ProcessBuilder pb = new ProcessBuilder(this.args);
    if (this.cwd != null && AdakiteUtils.directoryExists(this.cwd)) {
      /* Set current working directory for the new process. */
      pb.directory(this.cwd.toFile());
    }

    this.process = pb.start();

    this.gobblerStdout = new StreamGobbler(this.process.getInputStream());
    this.gobblerStderr = new StreamGobbler(this.process.getErrorStream());
    this.gobblerStdout.start();
    this.gobblerStderr.start();
  }

  /**
   * Attempts to close the pipe.
   */
  public void close() {
    this.gobblerStdout.interrupt();
    this.gobblerStdout.interrupt();
    this.process.destroy();
    if (this.process.isAlive()) {
      LOGGER.warn("process is still alive after destroy attempt");
    }
  }

}

@@ -424,33 +424,8 @@
 ss;%0A
-  private String%5B%5D args;%0A
   pr
@@ -440,16 +440,16 @@
 th cwd;%0A
+
   privat
@@ -575,30 +575,8 @@
 ll;%0A
-    this.args = null;%0A
     
@@ -615,32 +615,32 @@
 rStdout = null;%0A
+
     this.gobbler
@@ -663,131 +663,8 @@
  %7D%0A%0A
-  /**%0A   * Returns the current working directory for the process.%0A   */%0A  public Path getCWD() %7B%0A    return this.cwd;%0A  %7D%0A%0A
   /*
@@ -1170,31 +1170,8 @@
  %7D%0A%0A
-    this.args = args;%0A%0A
     
@@ -1209,21 +1209,16 @@
 Builder(
-this.
 args);%0A 

Remove "private String[] args" from "CustomProcess.java"