|
16 | 16 | // under the License.
|
17 | 17 | package org.openqa.selenium.manager;
|
18 | 18 |
|
19 |
| -import org.openqa.selenium.Beta; |
20 |
| -import org.openqa.selenium.Capabilities; |
21 |
| -import org.openqa.selenium.Platform; |
22 |
| -import org.openqa.selenium.Proxy; |
23 |
| -import org.openqa.selenium.WebDriverException; |
24 |
| -import org.openqa.selenium.json.Json; |
25 |
| -import org.openqa.selenium.json.JsonException; |
26 |
| -import org.openqa.selenium.manager.SeleniumManagerOutput.Result; |
27 |
| -import org.openqa.selenium.os.CommandLine; |
| 19 | +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; |
| 20 | +import static org.openqa.selenium.Platform.MAC; |
| 21 | +import static org.openqa.selenium.Platform.WINDOWS; |
28 | 22 |
|
29 | 23 | import java.io.IOException;
|
30 | 24 | import java.io.InputStream;
|
|
39 | 33 | import java.util.Map;
|
40 | 34 | import java.util.logging.Level;
|
41 | 35 | import java.util.logging.Logger;
|
42 |
| - |
43 |
| -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; |
44 |
| -import static org.openqa.selenium.Platform.MAC; |
45 |
| -import static org.openqa.selenium.Platform.WINDOWS; |
| 36 | +import org.openqa.selenium.Beta; |
| 37 | +import org.openqa.selenium.Capabilities; |
| 38 | +import org.openqa.selenium.Platform; |
| 39 | +import org.openqa.selenium.Proxy; |
| 40 | +import org.openqa.selenium.WebDriverException; |
| 41 | +import org.openqa.selenium.json.Json; |
| 42 | +import org.openqa.selenium.json.JsonException; |
| 43 | +import org.openqa.selenium.manager.SeleniumManagerOutput.Result; |
| 44 | +import org.openqa.selenium.os.CommandLine; |
46 | 45 |
|
47 | 46 | /**
|
48 | 47 | * This implementation is still in beta, and may change.
|
@@ -112,10 +111,11 @@ private static Result runCommand(Path binary, List<String> arguments) {
|
112 | 111 | String output;
|
113 | 112 | int code;
|
114 | 113 | try {
|
115 |
| - CommandLine command = new CommandLine(binary.toAbsolutePath().toString(), arguments.toArray(new String[0])); |
| 114 | + CommandLine command = |
| 115 | + new CommandLine(binary.toAbsolutePath().toString(), arguments.toArray(new String[0])); |
116 | 116 | command.copyOutputTo(System.err);
|
117 | 117 | command.executeAsync();
|
118 |
| - command.waitFor(10000); // A generous timeout |
| 118 | + command.waitFor(10000); // A generous timeout |
119 | 119 | if (command.isRunning()) {
|
120 | 120 | LOG.warning("Selenium Manager did not exit");
|
121 | 121 | }
|
@@ -146,17 +146,11 @@ private static Result runCommand(Path binary, List<String> arguments) {
|
146 | 146 | }
|
147 | 147 | if (code != 0) {
|
148 | 148 | throw new WebDriverException(
|
149 |
| - "Command failed with code: " |
150 |
| - + code |
151 |
| - + ", executed: " |
152 |
| - + arguments |
153 |
| - + "\n" |
154 |
| - + dump, |
| 149 | + "Command failed with code: " + code + ", executed: " + arguments + "\n" + dump, |
155 | 150 | failedToParse);
|
156 | 151 | } else if (failedToParse != null || jsonOutput == null) {
|
157 | 152 | throw new WebDriverException(
|
158 |
| - "Failed to parse json output, executed: " + arguments + "\n" + dump, |
159 |
| - failedToParse); |
| 153 | + "Failed to parse json output, executed: " + arguments + "\n" + dump, failedToParse); |
160 | 154 | }
|
161 | 155 | return jsonOutput.result;
|
162 | 156 | }
|
@@ -198,27 +192,32 @@ private synchronized Path getBinary() {
|
198 | 192 | }
|
199 | 193 |
|
200 | 194 | private void deleteOnExit(Path tmpPath) {
|
201 |
| - Runtime.getRuntime().addShutdownHook(new Thread(() -> { |
202 |
| - try { |
203 |
| - Files.walkFileTree( |
204 |
| - tmpPath, |
205 |
| - new SimpleFileVisitor<Path>() { |
206 |
| - @Override |
207 |
| - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { |
208 |
| - Files.delete(dir); |
209 |
| - return FileVisitResult.CONTINUE; |
210 |
| - } |
| 195 | + Runtime.getRuntime() |
| 196 | + .addShutdownHook( |
| 197 | + new Thread( |
| 198 | + () -> { |
| 199 | + try { |
| 200 | + Files.walkFileTree( |
| 201 | + tmpPath, |
| 202 | + new SimpleFileVisitor<Path>() { |
| 203 | + @Override |
| 204 | + public FileVisitResult postVisitDirectory(Path dir, IOException exc) |
| 205 | + throws IOException { |
| 206 | + Files.delete(dir); |
| 207 | + return FileVisitResult.CONTINUE; |
| 208 | + } |
211 | 209 |
|
212 |
| - @Override |
213 |
| - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { |
214 |
| - Files.delete(file); |
215 |
| - return FileVisitResult.CONTINUE; |
216 |
| - } |
217 |
| - }); |
218 |
| - } catch (IOException e) { |
219 |
| - // Do nothing. We're just tidying up. |
220 |
| - } |
221 |
| - })); |
| 210 | + @Override |
| 211 | + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) |
| 212 | + throws IOException { |
| 213 | + Files.delete(file); |
| 214 | + return FileVisitResult.CONTINUE; |
| 215 | + } |
| 216 | + }); |
| 217 | + } catch (IOException e) { |
| 218 | + // Do nothing. We're just tidying up. |
| 219 | + } |
| 220 | + })); |
222 | 221 | }
|
223 | 222 |
|
224 | 223 | /**
|
|
0 commit comments