[ https://issues.apache.org/jira/browse/CB-135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bryce Curtis resolved CB-135. ----------------------------- Resolution: Fixed Fix Version/s: 1.4.0 Added synchronized to protect LinkedList javascript variable. > Multithreaded access on CallbackServer javascript object > -------------------------------------------------------- > > Key: CB-135 > URL: https://issues.apache.org/jira/browse/CB-135 > Project: Apache Callback > Issue Type: Bug > Components: Android > Affects Versions: 1.0.0, 1.2.0 > Reporter: Gwyn Judd > Assignee: Bryce Curtis > Fix For: 1.4.0 > > > 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) { > synchronized (this) { > this.empty = true; > } > } > return statement; > } > > /** > * Add a JavaScript statement to the list. > * > * @param statement > */ > public void sendJavascript(String statement) { > > //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. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira