Skip to content

Commit

Permalink
KristianRosenvold: Fixed memory model issue WebRemoteProxy
Browse files Browse the repository at this point in the history
Both variables were provably accessible to different threads by code review

r13620
  • Loading branch information
krosenvold committed Aug 26, 2011
1 parent 8ec568d commit bb56455
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ java/client/src/org/openqa/selenium/ie/IeReturnTypes.java
.idea/misc.xml
.idea/workspace.xml
.idea/projectCodeStyle.xml
.idea/*
out
cpp/IEDriver/sizzle.h
third_party/gecko-2/linux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ public HtmlRenderer getHtmlRender() {
/*
* Self Healing part.Polls the remote, and marks it down if it cannot be reached twice in a row.
*/
private boolean down = false;
private boolean poll = true;
int nbFailedPoll = 0;
private volatile boolean down = false;
private volatile boolean poll = true;
// TODO freynaud
private List<RemoteException> errors = new CopyOnWriteArrayList<RemoteException>();
private Thread pollingThread = null;
Expand All @@ -113,6 +112,8 @@ public boolean isAlive() {

public void startPolling() {
pollingThread = new Thread(new Runnable() {
int nbFailedPoll = 0;

public void run() {
while (poll) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void test() throws MalformedURLException, InterruptedException {
@Test(dependsOnMethods = "test")
public void sendMoreRequests() throws MalformedURLException {
for (int i = 0; i < 5; i++) {
new Thread(new Runnable() {
new Thread(new Runnable() { // Thread safety reviewed
public void run() {
DesiredCapabilities ff = DesiredCapabilities.firefox();
try {
Expand All @@ -101,8 +101,8 @@ public void run() {
}
}

WebDriver importantOne;
boolean importantOneStarted = false;
volatile WebDriver importantOne;
volatile boolean importantOneStarted = false;

// adding a request with high priority at the end of the queue
@Test(dependsOnMethods = "sendMoreRequests", timeOut = 30000)
Expand All @@ -117,7 +117,7 @@ public void sendTheImportantOne() throws MalformedURLException, InterruptedExcep
final DesiredCapabilities ff = DesiredCapabilities.firefox();
ff.setCapability("_important", true);

new Thread(new Runnable() {
new Thread(new Runnable() { // Thread safety reviewed
public void run() {
try {
importantOne = new RemoteWebDriver(new URL(hubURL + "/grid/driver"), ff);
Expand All @@ -135,7 +135,7 @@ public void run() {
@Test(dependsOnMethods = "sendTheImportantOne")
public void sendMoreRequests2() throws MalformedURLException {
for (int i = 0; i < 5; i++) {
new Thread(new Runnable() {
new Thread(new Runnable() { // Thread safety reviewed
public void run() {
DesiredCapabilities ff = DesiredCapabilities.firefox();
try {
Expand Down

0 comments on commit bb56455

Please sign in to comment.