I have found a couple problems with running Rhino 1.5R2 in a heavily
multi-threaded environment.  The attached patches fix the problems.

- org.mozilla.javascript.optimizer.InvokerImpl - This class was accessing
the shared classNumber outside of the synchronized block.

- org.mozilla.javascript.optimizer.OptClassNameHelper - The reset method was
not synchronized.  It needs to be because the class using the classNames map
is synchronized and does not handle nulling of the variable while it's
looping on the map.

Jeff
This commit is contained in:
nboyd%atg.com 2001-09-05 16:50:26 +00:00
Родитель f6c7331ba4
Коммит 41d71ed1c7
2 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -56,11 +56,12 @@ public class InvokerImpl extends Invoker {
Invoker result = (Invoker)invokersCache.get(method);
if (result != null) { return result; }
int classNum = 0;
synchronized (this) {
++classNumber;
classNum = ++classNumber;
}
String className = "inv" + classNumber;
String className = "inv" + classNum;
ClassFileWriter cfw = new ClassFileWriter(className,
"org.mozilla.javascript.Invoker", "");

Просмотреть файл

@ -51,7 +51,7 @@ public class OptClassNameHelper implements ClassNameHelper {
return generatingDirectory;
}
public void reset() {
public synchronized void reset() {
classNames = null;
}