Skip to content

Commit ce707f2

Browse files
committed
fix getData mapper func
1 parent 2817776 commit ce707f2

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

java/src/org/openqa/selenium/bidi/module/Network.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.openqa.selenium.bidi.module;
1919

20-
import java.io.StringReader;
2120
import java.util.Collections;
2221
import java.util.HashSet;
2322
import java.util.List;
@@ -43,15 +42,12 @@
4342
import org.openqa.selenium.bidi.network.ProvideResponseParameters;
4443
import org.openqa.selenium.bidi.network.ResponseDetails;
4544
import org.openqa.selenium.internal.Require;
46-
import org.openqa.selenium.json.Json;
4745
import org.openqa.selenium.json.JsonInput;
4846

4947
public class Network implements AutoCloseable {
5048

5149
private final Set<String> browsingContextIds;
5250

53-
private static final Json JSON = new Json();
54-
5551
private final BiDi bidi;
5652

5753
private final Event<BeforeRequestSent> beforeRequestSentEvent =
@@ -71,13 +67,18 @@ public class Network implements AutoCloseable {
7167

7268
private final Function<JsonInput, BytesValue> getDataResultMapper =
7369
jsonInput -> {
74-
Map<String, Object> result = jsonInput.read(Map.class);
75-
Object bytesObj = result.get("bytes");
76-
77-
try (StringReader reader = new StringReader(JSON.toJson(bytesObj));
78-
JsonInput bytesInput = JSON.newInput(reader)) {
79-
return BytesValue.fromJson(bytesInput);
70+
jsonInput.beginObject();
71+
BytesValue bytes = null;
72+
while (jsonInput.hasNext()) {
73+
String name = jsonInput.nextName();
74+
if ("bytes".equals(name)) {
75+
bytes = BytesValue.fromJson(jsonInput);
76+
} else {
77+
jsonInput.skipValue();
78+
}
8079
}
80+
jsonInput.endObject();
81+
return bytes;
8182
};
8283

8384
public Network(WebDriver driver) {

0 commit comments

Comments
 (0)