spring-projects / spring-webflow

Spring Web Flow
https://spring.io/projects/spring-webflow
322 stars 228 forks source link

SimpleELContext is not thread-safe [SWF-976] #1657

Closed spring-operator closed 15 years ago

spring-operator commented 15 years ago

Vladimir Kralik opened SWF-976 and commented

Class SimpleELContext extends javax.el.Context. Javadoc http://java.sun.com/products/jsp/2.1/docs/jsp-2_1-pfd2/javax/el/ELContext.html said : """" Because it stores state during expression evaluation, an ELContext object is not thread-safe """.

Instance of SimpleELContext is stored in ELDelegatingPropertyResolver and ELDelegatingVariableResolver, which are application singletons, so this instance of SimpleELContext is shared for all sessions.

This bug is very strange, because in single user development/testing everything works fine, but in production with more users, we got usually NullPointerException on bizzarre places in program like this :

String label = getItemLabel() != null ? getItemLabel().toString() : null;

Attachment contains a patch, which helps me.


Affects: 2.0.5

Attachments:

spring-operator commented 15 years ago

Peter Hamlen commented

Just some testing results:

We had this problem on our application and were able to consistently reproduce it by having two users submit the same form of a complex page at the same time. (Specifically, we could reproduce it 20 out of 20 times and had debugged it down to the SimpleELContext before we found this Jira bug.)

We then applied the patch to a fresh copy of 2.0.5.RELEASE source from svn and it eliminated the problem (and all other related problems.)

It also had no noticeable impact on performance when we ran our load testing (we have a standard loadtest and there was no difference in the numbers.)

In addition, we actually tested this patch using both the SUN Mojarra RI implementation and MyFaces 1.2.6 and using two different EL engines (UEL and an Ognl EL variant.) It worked on all variations.

-Peter Hamlen (phamlen at mail.com)