Skip to content

Commit

Permalink
KristianRosenvold: Made killable logic only kill browser, not interru…
Browse files Browse the repository at this point in the history
…pt thread

Using any kind of interrupted logic to detect session timeout seems like the Wrong Thing To Do

r16454
  • Loading branch information
krosenvold committed Apr 4, 2012
1 parent a458082 commit b456bec
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
1 change: 0 additions & 1 deletion java/client/src/org/openqa/selenium/remote/ErrorCodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class ErrorCodes {
public static final int INVALID_XPATH_SELECTOR = 51;
public static final int INVALID_XPATH_SELECTOR_RETURN_TYPER = 52;
// The following error codes are derived straight from HTTP return codes.
public static final int GONE = 404;
public static final int METHOD_NOT_ALLOWED = 405;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private HttpResponse fallBackExecute(HttpContext context, HttpUriRequest httpMet
try {
Thread.sleep(2000);
} catch (InterruptedException ie) {
throw new SessionTerminatedException();
throw Throwables.propagate(ie);
}
}
return client.execute(targetHost, httpMethod, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ public enum SessionTerminationReason {
CLIENT_GONE,
FORWARDING_TO_NODE_FAILED,
CREATIONFAILED,
PROXY_REREGISTRATION
}
PROXY_REREGISTRATION,
SO_TIMEOUT
}
1 change: 1 addition & 0 deletions java/server/src/org/openqa/grid/internal/TestSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ private HttpClient getClient() {
if (browserTimeout > 0){
final int selenium_server_cleanup_cycle = browserTimeout / 10;
browserTimeout += (selenium_server_cleanup_cycle + MAX_NETWORK_LATENCY);
browserTimeout *=2; // Lets not let this happen too often
}
return slot.getProxy().getHttpClientFactory().getGridHttpClient(browserTimeout);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.openqa.grid.web.servlet.handler;

import java.io.IOException;
import java.net.SocketTimeoutException;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -127,6 +128,8 @@ public void process() {
} catch (ClientGoneException e) {
log.log(Level.WARNING, "The client is gone for session " + session + ", terminating");
registry.terminate(session, SessionTerminationReason.CLIENT_GONE);
} catch (SocketTimeoutException e){
registry.terminate(session, SessionTerminationReason.SO_TIMEOUT);
} catch (Throwable t) {
log.log(Level.SEVERE, "cannot forward the request " + t.getMessage(), t);
registry.terminate(session, SessionTerminationReason.FORWARDING_TO_NODE_FAILED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class SessionCleaner extends Thread { // Thread safety reviewed
if (clientGoneTimeout == 0 && insideBrowserTimeout == 0){
throw new IllegalStateException("SessionCleaner not supposed to start when no timeouts specified");
}
if (insideBrowserTimeout > 0 && insideBrowserTimeout < 60000){
log.warning("The specified browser timeout is TOO LOW for safe operations and may have"+
"other side-effects\n. Please specify a slightly higher browserTimeout.");
}
int lowestNonZero = Math.min((insideBrowserTimeout > 0) ? insideBrowserTimeout : clientGoneTimeout,
clientGoneTimeout > 0 ? clientGoneTimeout : insideBrowserTimeout);
this.sleepInterval = lowestNonZero / 10;
Expand Down Expand Up @@ -89,7 +93,7 @@ void checkExpiry() {
driver = ((EventFiringWebDriver)driver).getWrappedDriver();
}
if (driver instanceof Killable) {
session.interrupt();
//session.interrupt();
((Killable) driver).kill();
killed = true;
log.warning("Browser killed and session " + session.getSessionId() + " terminated due to in-browser timeout.");
Expand Down

0 comments on commit b456bec

Please sign in to comment.