Obsolete Application instance is used by expressions from cache of
ValueBindingImpl
-------------------------------------------------------------------------------------
Key: MYFACES-1354
URL: http://issues.apache.org/jira/browse/MYFACES-1354
Project: MyFaces Core
Type: Bug
Versions: 1.1.3, 1.1.5-SNAPSHOT
Environment: JBoss 4.0.4.GA
Reporter: Alexander Slobodyanik
Priority: Minor
Hi,
I'm using custom PropertyResolver and it works fine until first redeployment of
web application. After that, it throws ClassCastException's. I've found out,
that while new PropertyResolver instance is created during every deployment,
for every EL expression evaluation that instance is used, which was used for
it's first evaluation. So the source of linkage errors is that classes of
objects, passed to PropertyResolver instance, were loaded by different
classloaders (for each of web app deployments).
After searching the source code I've found the source of problem: static
BiLevelCacheMap s_expressionCache in ValueBindingImpl. It stores expressions,
parsed from strings by ELParserHelper, and during parsing link to current
Application is passed to these expressions:
private static void replaceSuffixes(ComplexValue complexValue)
{
Application application = FacesContext.getCurrentInstance()
.getApplication();
List suffixes = complexValue.getSuffixes();
for (int i = 0, len = suffixes.size(); i < len; i++)
{
ValueSuffix suffix = (ValueSuffix) suffixes.get(i);
if (suffix instanceof PropertySuffix)
{
if (suffix instanceof MyPropertySuffix)
{
throw new IllegalStateException(
"Suffix is MyPropertySuffix and must not be");
}
suffixes.set(i, new MyPropertySuffix((PropertySuffix) suffix,
application));
}
....
Then, once some EL expression in JSP page was first evaluated, current
Application instance (and, accordingly, its PropertyResolver instance) will be
used for all subsequent evaluations of the same expression, even after
redeployment of web app and new Application intance creation.
I can workaround this issue by using code like this:
public Object getValue(Object base, Object property) throws
EvaluationException, PropertyNotFoundException {
javax.faces.el.PropertyResolver actual =
FacesContext.getCurrentInstance().getApplication().getPropertyResolver();
if (this != actual) return actual.getValue(base, property);
...
at the start of each methos of PropertyResolver.
Regards,
Alexander
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira