[FIX] avoid UnreachableBrowserException when creating WebDriver instance #14
+11
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Avoid multiple call for org.webbitserver.HttpResponse#end(), which flushes http response to tcp stream in rare cases. This causes UnreachableBrowserException when creating WebDriver instance (see exception message below [*1]).
Detail:
When a test code creates WebDriver instance, WebDriver(client) sends new session request. If WebDriver(server) receives that request, server renders response using RedirectResult#render() and flushes it using WebbitHttpResponse#end().
But there's a issue that WebbitHttpResponse#end() is called two times (see below[*2]).
WebbitHttpResponse#end() calls Webbit's NettyHttpResponse#end() that flushes http response to tcp stream. So WebDriver client gets same response two times as described below:
If WebDriver client gets redirect response two times, a CircularRedirectException will be thrown by apache http client which results in UnreachableBrowserException.
That's why WebbitHttpResponse should call webbit's HttpResponse#end() just one time.
Remarks:
(*1) UnreachableBrowserException Stacktrace
(*2) Caller of WebbitHttpResponse#end()
first one is:
second one is either of them below:
-> org.openqa.selenium.remote.server.WebbitHttpResponse#sendRedirect()
Reproduction Code: