Skip to content

Commit bb56455

Browse files
committed
KristianRosenvold: Fixed memory model issue WebRemoteProxy
Both variables were provably accessible to different threads by code review r13620
1 parent 8ec568d commit bb56455

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ java/client/src/org/openqa/selenium/ie/IeReturnTypes.java
2626
.idea/misc.xml
2727
.idea/workspace.xml
2828
.idea/projectCodeStyle.xml
29+
.idea/*
2930
out
3031
cpp/IEDriver/sizzle.h
3132
third_party/gecko-2/linux

java/server/src/org/openqa/grid/selenium/proxy/WebRemoteProxy.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ public HtmlRenderer getHtmlRender() {
8686
/*
8787
* Self Healing part.Polls the remote, and marks it down if it cannot be reached twice in a row.
8888
*/
89-
private boolean down = false;
90-
private boolean poll = true;
91-
int nbFailedPoll = 0;
89+
private volatile boolean down = false;
90+
private volatile boolean poll = true;
9291
// TODO freynaud
9392
private List<RemoteException> errors = new CopyOnWriteArrayList<RemoteException>();
9493
private Thread pollingThread = null;
@@ -113,6 +112,8 @@ public boolean isAlive() {
113112

114113
public void startPolling() {
115114
pollingThread = new Thread(new Runnable() {
115+
int nbFailedPoll = 0;
116+
116117
public void run() {
117118
while (poll) {
118119
try {

java/server/test/org/openqa/grid/e2e/wd/WebDriverPriorityDemo.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void test() throws MalformedURLException, InterruptedException {
8888
@Test(dependsOnMethods = "test")
8989
public void sendMoreRequests() throws MalformedURLException {
9090
for (int i = 0; i < 5; i++) {
91-
new Thread(new Runnable() {
91+
new Thread(new Runnable() { // Thread safety reviewed
9292
public void run() {
9393
DesiredCapabilities ff = DesiredCapabilities.firefox();
9494
try {
@@ -101,8 +101,8 @@ public void run() {
101101
}
102102
}
103103

104-
WebDriver importantOne;
105-
boolean importantOneStarted = false;
104+
volatile WebDriver importantOne;
105+
volatile boolean importantOneStarted = false;
106106

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

120-
new Thread(new Runnable() {
120+
new Thread(new Runnable() { // Thread safety reviewed
121121
public void run() {
122122
try {
123123
importantOne = new RemoteWebDriver(new URL(hubURL + "/grid/driver"), ff);
@@ -135,7 +135,7 @@ public void run() {
135135
@Test(dependsOnMethods = "sendTheImportantOne")
136136
public void sendMoreRequests2() throws MalformedURLException {
137137
for (int i = 0; i < 5; i++) {
138-
new Thread(new Runnable() {
138+
new Thread(new Runnable() { // Thread safety reviewed
139139
public void run() {
140140
DesiredCapabilities ff = DesiredCapabilities.firefox();
141141
try {

0 commit comments

Comments
 (0)