Skip to content

Commit

Permalink
There's no apparent reason that the response for a WebDriverHandler-b…
Browse files Browse the repository at this point in the history
…ased

command must be rendered in a separate thread than that which executed
the command, so removing this extra complexity. If there was a reason
things were done this way, there really should be a comment documenting
it.  All tests pass with this change, so I'm assuming it is safe.
  • Loading branch information
jleyba committed Dec 31, 2013
1 parent e38abc6 commit b04a82d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ protected BySelector newBySelector() {
return new BySelector();
}

public void execute(FutureTask<?> task) throws Exception {
Session session = getSession();
if (session != null)
session.execute(task);
else
task.run();
}

protected WebDriver getUnwrappedDriver() {
WebDriver toReturn = getDriver();
while (toReturn instanceof WrapsDriver) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,34 +234,15 @@ public void handle(String pathInfo, final HttpRequest request,

final Renderer renderer = getRenderer(result, request);

if (handler instanceof WebDriverHandler) {
FutureTask<ResultType> task = new FutureTask<ResultType>(new Callable<ResultType>() {
public ResultType call() throws Exception {
renderer.render(request, response, handler);
response.end();
return null;
}
});

try {
((WebDriverHandler) handler).execute(task);
task.get();
} catch (RejectedExecutionException e){
throw new SessionNotFoundException();
}

if (handler instanceof DeleteSession) {
// Yes, this is funky. See javadoc on cleatThreadTempLogs for details.
final PerSessionLogHandler logHandler = LoggingManager.perSessionLogHandler();
logHandler.transferThreadTempLogsToSessionLogs(sessId);
logHandler.removeSessionLogs(sessId);
sessions.deleteSession(sessId);
}


} else {
renderer.render(request, response, handler);
response.end();
renderer.render(request, response, handler);
response.end();

if (handler instanceof DeleteSession) {
// Yes, this is funky. See javadoc on cleatThreadTempLogs for details.
final PerSessionLogHandler logHandler = LoggingManager.perSessionLogHandler();
logHandler.transferThreadTempLogsToSessionLogs(sessId);
logHandler.removeSessionLogs(sessId);
sessions.deleteSession(sessId);
}
}

Expand Down

0 comments on commit b04a82d

Please sign in to comment.