Skip to content

Commit

Permalink
Avoid re-inventing wheels with null output streams.
Browse files Browse the repository at this point in the history
I'm pretty sure that there's at least one of these in our
own codebase too.
  • Loading branch information
shs96c committed Apr 11, 2017
1 parent 6c7b4b4 commit 7ba1186
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.ByteStreams;

//import org.apache.commons.io.output.NullOutputStream;
import org.openqa.selenium.WebDriverException;
Expand Down Expand Up @@ -135,6 +136,7 @@ protected GeckoDriverService createDriverService(File exe, int port,
try {
GeckoDriverService service = new GeckoDriverService(exe, port, args, environment);
if (getLogFile() != null) {
// TODO: This stream is leaked.
service.sendOutputTo(new FileOutputStream(getLogFile()));
} else {
String firefoxLogFile = System.getProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE);
Expand All @@ -144,12 +146,9 @@ protected GeckoDriverService createDriverService(File exe, int port,
} else if ("/dev/stderr".equals(firefoxLogFile)) {
service.sendOutputTo(System.err);
} else if ("/dev/null".equals(firefoxLogFile)) {
service.sendOutputTo(new OutputStream() {
@Override
public void write(int b) throws IOException {
}
});
service.sendOutputTo(ByteStreams.nullOutputStream());
} else {
// TODO: The stream is leaked.
service.sendOutputTo(new FileOutputStream(firefoxLogFile));
}
}
Expand Down

0 comments on commit 7ba1186

Please sign in to comment.