Skip to content

Commit

Permalink
Remove unnecessary parameter from JsonOutput.write
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Mar 13, 2018
1 parent 121bb31 commit d7fe2c4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions java/client/src/org/openqa/selenium/json/JsonOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.Closeable;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.reflect.Type;

public class JsonOutput implements Closeable {
private final JsonWriter jsonWriter;
Expand All @@ -39,17 +38,17 @@ public void close() throws IOException {
jsonWriter.close();
}

public JsonOutput write(JsonInput input, Type type) {
public JsonOutput write(JsonInput input) {
try {
Object read = input.read(type);
Object read = input.read(Json.OBJECT_TYPE);
jsonWriter.jsonValue(toJson.convert(read));
return this;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

public JsonOutput write(Object input, Type type) {
public JsonOutput write(Object input) {
try {
jsonWriter.jsonValue(toJson.convert(input));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,22 +229,22 @@ public void writeTo(Appendable appendable) throws IOException {

// Write the first capability we get as the desired capability.
json.name("desiredCapabilities");
json.write(first, MAP_TYPE);
json.write(first);

// And write the first capability for gecko13
json.name("capabilities");
json.beginObject();

json.name("desiredCapabilities");
json.write(first, MAP_TYPE);
json.write(first);

// Then write everything into the w3c payload. Because of the way we do this, it's easiest
// to just populate the "firstMatch" section. The spec says it's fine to omit the
// "alwaysMatch" field, so we do this.
json.name("firstMatch");
json.beginArray();
//noinspection unchecked
getW3C().forEach(map -> json.write(map, MAP_TYPE));
getW3C().forEach(map -> json.write(map));
json.endArray();

json.endObject(); // Close "capabilities" object
Expand All @@ -271,7 +271,7 @@ private void writeMetaData(JsonOutput out) throws IOException {

default:
out.name(name);
out.write(input.<Object>read(Object.class), Object.class);
out.write(input.<Object>read(Object.class));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO
.forEach((key, value) -> {
json.name(key);
json.beginArray();
Stream.of(value).forEach(v -> json.write(v, String.class));
Stream.of(value).forEach(json::write);
json.endArray();
});
json.endObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected void process(HttpServletRequest request, HttpServletResponse response)
try (Writer writer = response.getWriter();
JsonOutput out = json.newOutput(writer)) {
Map<String, Object> res = getResponse(request);
out.write(res, MAP_TYPE);
out.write(res);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected void process(HttpServletRequest request, HttpServletResponse response)
response.setStatus(200);
try (Writer writer = response.getWriter();
JsonOutput out = json.newOutput(writer)){
out.write(getResponse(request), MAP_TYPE);
out.write(getResponse(request));
} catch (JsonException e) {
throw new GridException(e.getMessage());
}
Expand Down

0 comments on commit d7fe2c4

Please sign in to comment.