[ https://issues.apache.org/jira/browse/OGNL-145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13859932#comment-13859932 ]
Sebb commented on OGNL-145: --------------------------- Mutable static data is always likely to be a problem for multi-threaded apps, and in particular for jars that need to be shared across apps. Even if the mutable data is correctly updated using synchronisation etc, such data is generally thread-hostile, as it is not possible to maintain different data for different threads in the same app, nor for different apps sharing the same jar. Some specific types of mutable data are OK. For example, a global sequence number would be fine (assuming the data is updated and published safely) Likewise it would be OK to have a static collection that is initialised once and not updated subsequently. It might also be OK to have a shared cache. It does not look OK to allow such fields as private static OgnlExpressionCompiler compiler; which can be updated at any time using a public setter. Even if the field is only set once and never changed subsequently, there is a problem with the code. This is because the field is written and read without synchronisation. The Java memory model requires synchronisation in order to guarantee safe publication of variables across threads. This is because the modell allows threads to cache values locally. As it stands, thread A can set the field, and thread B might never see the updated value. > Remove all static state. > ------------------------- > > Key: OGNL-145 > URL: https://issues.apache.org/jira/browse/OGNL-145 > Project: Commons OGNL > Issue Type: New Feature > Components: Core Runtime > Affects Versions: 2.7.3 > Environment: any > Reporter: Jesse Kuhnert > Assignee: Jesse Kuhnert > Fix For: 4.0 > > > The static state management in OgnlRuntime is causing havoc with classloaders > where people run multiple instances of tapestry apps with shared jar > references to OGNL. Need to finally do the "big refactor" that removes all > static state from OGNL. -- This message was sent by Atlassian JIRA (v6.1.5#6160)