Skip to content

Commit 1ee4133

Browse files
committed
[java] Use internal JSON parser instead of GSON
1 parent b1715b8 commit 1ee4133

File tree

3 files changed

+67
-11
lines changed

3 files changed

+67
-11
lines changed

java/src/org/openqa/selenium/manager/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ java_export(
1818
],
1919
deps = [
2020
"//java/src/org/openqa/selenium:core",
21+
"//java/src/org/openqa/selenium/json",
2122
artifact("com.google.guava:guava"),
22-
artifact("com.google.code.gson:gson"),
2323
],
2424
)
2525

java/src/org/openqa/selenium/manager/SeleniumManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
import com.google.common.collect.ImmutableList;
2020
import com.google.common.io.CharStreams;
21-
import com.google.gson.GsonBuilder;
2221
import org.openqa.selenium.Beta;
2322
import org.openqa.selenium.Capabilities;
2423
import org.openqa.selenium.Platform;
2524
import org.openqa.selenium.WebDriverException;
25+
import org.openqa.selenium.json.Json;
2626

2727
import java.io.File;
2828
import java.io.IOException;
@@ -113,7 +113,7 @@ private static String runCommand(String... command) {
113113
throw new WebDriverException("Unsuccessful command executed: " + Arrays.toString(command) +
114114
"\n" + output);
115115
}
116-
SeleniumManagerJsonOutput jsonOutput = new GsonBuilder().create().fromJson(output,
116+
SeleniumManagerJsonOutput jsonOutput = new Json().toType(output,
117117
SeleniumManagerJsonOutput.class);
118118
jsonOutput.logs.stream().filter(log -> log.level.equalsIgnoreCase(WARN))
119119
.forEach(log -> LOG.warning(log.message));

java/src/org/openqa/selenium/manager/SeleniumManagerJsonOutput.java

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,74 @@
2020

2121
public class SeleniumManagerJsonOutput {
2222

23-
List<Log> logs;
24-
Result result;
23+
public List<Log> logs;
24+
public Result result;
2525

26-
class Log {
27-
String level;
26+
public List<Log> getLogs() {
27+
return logs;
28+
}
29+
30+
public void setLogs(List<Log> logs) {
31+
this.logs = logs;
32+
}
33+
34+
public Result getResult() {
35+
return result;
36+
}
37+
38+
public void setResult(Result result) {
39+
this.result = result;
40+
}
41+
42+
public static class Log {
43+
public String level;
2844
long timestamp;
29-
String message;
45+
public String message;
46+
47+
public String getLevel() {
48+
return level;
49+
}
50+
51+
public void setLevel(String level) {
52+
this.level = level;
53+
}
54+
55+
public long getTimestamp() {
56+
return timestamp;
57+
}
58+
59+
public void setTimestamp(long timestamp) {
60+
this.timestamp = timestamp;
61+
}
62+
63+
public String getMessage() {
64+
return message;
65+
}
66+
67+
public void setMessage(String message) {
68+
this.message = message;
69+
}
3070
}
3171

32-
class Result {
33-
int code;
34-
String message;
72+
public static class Result {
73+
public int code;
74+
public String message;
75+
76+
public int getCode() {
77+
return code;
78+
}
79+
80+
public void setCode(int code) {
81+
this.code = code;
82+
}
83+
84+
public String getMessage() {
85+
return message;
86+
}
87+
88+
public void setMessage(String message) {
89+
this.message = message;
90+
}
3591
}
3692

3793
}

0 commit comments

Comments
 (0)