Skip to content

Commit 7ba1186

Browse files
committed
Avoid re-inventing wheels with null output streams.
I'm pretty sure that there's at least one of these in our own codebase too.
1 parent 6c7b4b4 commit 7ba1186

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

java/client/src/org/openqa/selenium/firefox/GeckoDriverService.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.google.common.collect.ImmutableList;
2424
import com.google.common.collect.ImmutableMap;
25+
import com.google.common.io.ByteStreams;
2526

2627
//import org.apache.commons.io.output.NullOutputStream;
2728
import org.openqa.selenium.WebDriverException;
@@ -135,6 +136,7 @@ protected GeckoDriverService createDriverService(File exe, int port,
135136
try {
136137
GeckoDriverService service = new GeckoDriverService(exe, port, args, environment);
137138
if (getLogFile() != null) {
139+
// TODO: This stream is leaked.
138140
service.sendOutputTo(new FileOutputStream(getLogFile()));
139141
} else {
140142
String firefoxLogFile = System.getProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE);
@@ -144,12 +146,9 @@ protected GeckoDriverService createDriverService(File exe, int port,
144146
} else if ("/dev/stderr".equals(firefoxLogFile)) {
145147
service.sendOutputTo(System.err);
146148
} else if ("/dev/null".equals(firefoxLogFile)) {
147-
service.sendOutputTo(new OutputStream() {
148-
@Override
149-
public void write(int b) throws IOException {
150-
}
151-
});
149+
service.sendOutputTo(ByteStreams.nullOutputStream());
152150
} else {
151+
// TODO: The stream is leaked.
153152
service.sendOutputTo(new FileOutputStream(firefoxLogFile));
154153
}
155154
}

0 commit comments

Comments
 (0)