Skip to content

Commit b636dd8

Browse files
committed
Fixing Marionette responce reading
1 parent 5c2a215 commit b636dd8

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Diff for: java/client/src/org/openqa/selenium/firefox/internal/MarionetteConnection.java

+15-5
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,27 @@ private String receiveResponse() throws IOException {
326326
char[] buf = new char[1024];
327327
int len = reader.read(buf);
328328
response.append(buf, 0, len);
329-
while (len >= 1024) {
329+
330+
String[] parts = response.toString().split(":", 2);
331+
int contentLength = Integer.parseInt(parts[0]);
332+
333+
while (response.length() < contentLength + ":".length() + parts[0].length()) {
330334
buf = new char[1024];
331335
len = reader.read(buf);
332-
response.append(buf, 0, len);
336+
if (len > 0) {
337+
response.append(buf, 0, len);
338+
} else {
339+
try {
340+
Thread.sleep(100);
341+
} catch (InterruptedException e) {
342+
}
343+
}
333344
}
334345

335346
System.out.println("<- |" + response.toString() + "|");
336347

337-
String[] parts = response.toString().split(":", 2);
338-
int length = Integer.parseInt(parts[0]);
339-
return parts[1].substring(0, length);
348+
parts = response.toString().split(":", 2);
349+
return parts[1].substring(0, contentLength);
340350
}
341351

342352
public void quit() {

0 commit comments

Comments
 (0)