* Do not cache nodes unless there is a request evaluator associated with
the current thread and we can invoke onInit() on it. This prevents nodes fetched from other applications to be cached and fixes bug 598 <http://helma.org/bugs/show_bug.cgi?id=598>
This commit is contained in:
parent
4f30dc3c0e
commit
b0723569b2
1 changed files with 11 additions and 4 deletions
|
@ -333,6 +333,16 @@ public final class NodeManager {
|
||||||
*/
|
*/
|
||||||
private Node registerNewNode(Node node, Key secondaryKey) {
|
private Node registerNewNode(Node node, Key secondaryKey) {
|
||||||
Key key = node.getKey();
|
Key key = node.getKey();
|
||||||
|
RequestEvaluator reval = app.getCurrentRequestEvaluator();
|
||||||
|
// if no request evaluator is associated with current thread, do not cache node
|
||||||
|
// as we cannot invoke onInit() on it.
|
||||||
|
if (reval == null) {
|
||||||
|
Node old = (Node) cache.get(key);
|
||||||
|
if (old != null && !old.isNullNode() && old.getState() != INode.INVALID) {
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
synchronized(cache) {
|
synchronized(cache) {
|
||||||
Node old = (Node) cache.put(key, node);
|
Node old = (Node) cache.put(key, node);
|
||||||
|
@ -352,10 +362,7 @@ public final class NodeManager {
|
||||||
try {
|
try {
|
||||||
// We need to reach deap into helma.framework.core to invoke onInit(),
|
// We need to reach deap into helma.framework.core to invoke onInit(),
|
||||||
// but the functionality is really worth it.
|
// but the functionality is really worth it.
|
||||||
RequestEvaluator reval = app.getCurrentRequestEvaluator();
|
reval.invokeDirectFunction(node, "onInit", RequestEvaluator.EMPTY_ARGS);
|
||||||
if (reval != null) {
|
|
||||||
reval.invokeDirectFunction(node, "onInit", RequestEvaluator.EMPTY_ARGS);
|
|
||||||
}
|
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
app.logError("Error invoking onInit()", x);
|
app.logError("Error invoking onInit()", x);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue