Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0.0, 1.2.0
-
None
Description
Any access to the list of javascript statements for the callbackserver class is only partially protected by synchronized critical sections. The three main culprits are here:
/**
- Get the number of JavaScript statements.
- @return int
*/
public int getSize() { int size = this.javascript.size(); //System.out.println("getSize() = " + size); return size; }
/**
- Get the next JavaScript statement and remove from list.
- @return String
*/
public String getJavascript() {
if (this.javascript.size() == 0) { return null; }String statement = this.javascript.remove(0);
//System.out.println("CallbackServer.getJavascript() = " + statement);
if (this.javascript.size() == 0)Unknown macro: { synchronized (this) { this.empty = true; } }return statement;
}
/**
- Add a JavaScript statement to the list.
- @param statement
*/
public void sendJavascript(String statement)Unknown macro: { //System.out.println("CallbackServer.sendJavascript("+statement+")"); this.javascript.add(statement); synchronized (this) { this.empty = false; this.notify(); } }
"this.javascript" is a LinkedList which is not synchronized. Therefore doing something like this "this.javascript.add(statement);" will not be thread safe and is likely to lead to corruption or other undefined behaviour.
Obviously these methods are meant to be called in a multithreaded manner because of the existence of the synchronized blocks - the "javascript" list should also be protected.