You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2012/05/01 07:30:31 UTC

svn commit: r1332526 - in /ofbiz/branches/release10.04: ./ framework/base/lib/ framework/base/src/org/ofbiz/base/util/ themes/bizznesstime/includes/ themes/droppingcrumbs/includes/ themes/flatgrey/includes/ themes/tomahawk/includes/

Author: jacopoc
Date: Tue May  1 05:30:31 2012
New Revision: 1332526

URL: http://svn.apache.org/viewvc?rev=1332526&view=rev
Log:
Backported 1308358, 1308368, 1308817 and 1328356:
* upgrade to freemarker 2.3.19
* the cache of parsed Groovy scripts was not thread safe; this issue, in instances with several concurrent threads running the same script the first time (i.e. not cached) could cause the same script parsed multiple times and then added to the cache (overriding the previous value); this event was causing the clearing of caches in Freemarker; because of a bug in Freemarker [*] this could cause a deadlock.
The issue is present on all versions of Freemarker but it is less frequent on latest version because of the refactoring of caches happened after release 2.3.10.
  
[*] https://sourceforge.net/tracker/?func=detail&aid=3519805&group_id=794&atid=100794


Added:
    ofbiz/branches/release10.04/framework/base/lib/freemarker-2.3.19.jar   (with props)
Removed:
    ofbiz/branches/release10.04/framework/base/lib/freemarker-2.3.15.jar
Modified:
    ofbiz/branches/release10.04/.classpath
    ofbiz/branches/release10.04/LICENSE
    ofbiz/branches/release10.04/framework/base/src/org/ofbiz/base/util/GroovyUtil.java
    ofbiz/branches/release10.04/themes/bizznesstime/includes/footer.ftl
    ofbiz/branches/release10.04/themes/droppingcrumbs/includes/footer.ftl
    ofbiz/branches/release10.04/themes/flatgrey/includes/footer.ftl
    ofbiz/branches/release10.04/themes/tomahawk/includes/footer.ftl

Modified: ofbiz/branches/release10.04/.classpath
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/.classpath?rev=1332526&r1=1332525&r2=1332526&view=diff
==============================================================================
--- ofbiz/branches/release10.04/.classpath (original)
+++ ofbiz/branches/release10.04/.classpath Tue May  1 05:30:31 2012
@@ -18,7 +18,7 @@
 	<classpathentry kind="lib" path="framework/base/lib/clhm-20100316.jar"/>
 	<classpathentry kind="lib" path="framework/base/lib/hamcrest-all-1.2.jar"/>
 	<classpathentry kind="lib" path="framework/base/lib/fop-0.95.jar"/>
-	<classpathentry kind="lib" path="framework/base/lib/freemarker-2.3.15.jar"/>
+	<classpathentry kind="lib" path="framework/base/lib/freemarker-2.3.19.jar"/>
 	<classpathentry kind="lib" path="framework/base/lib/httpclient-4.0.jar"/>
 	<classpathentry kind="lib" path="framework/base/lib/httpcore-4.0.1.jar"/>
 	<classpathentry kind="lib" path="framework/base/lib/httpunit.jar"/>

Modified: ofbiz/branches/release10.04/LICENSE
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/LICENSE?rev=1332526&r1=1332525&r2=1332526&view=diff
==============================================================================
--- ofbiz/branches/release10.04/LICENSE (original)
+++ ofbiz/branches/release10.04/LICENSE Tue May  1 05:30:31 2012
@@ -439,7 +439,7 @@ The JDOM License
 The following libraries distributed with Apache OFBiz are licensed under the
 BSD License:
 ofbiz/trunk/framework/base/lib/antisamy-bin.1.2.jar
-ofbiz/trunk/framework/base/lib/freemarker-2.3.15.jar
+ofbiz/trunk/framework/base/lib/freemarker-2.3.19.jar
 ofbiz/trunk/framework/base/lib/hamcrest-all-1.2.jar
 ofbiz/trunk/framework/base/lib/httpunit.jar
 ofbiz/trunk/framework/base/lib/ical4j-1.0-rc2.jar

Added: ofbiz/branches/release10.04/framework/base/lib/freemarker-2.3.19.jar
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/framework/base/lib/freemarker-2.3.19.jar?rev=1332526&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/branches/release10.04/framework/base/lib/freemarker-2.3.19.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: ofbiz/branches/release10.04/framework/base/src/org/ofbiz/base/util/GroovyUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/framework/base/src/org/ofbiz/base/util/GroovyUtil.java?rev=1332526&r1=1332525&r2=1332526&view=diff
==============================================================================
--- ofbiz/branches/release10.04/framework/base/src/org/ofbiz/base/util/GroovyUtil.java (original)
+++ ofbiz/branches/release10.04/framework/base/src/org/ofbiz/base/util/GroovyUtil.java Tue May  1 05:30:31 2012
@@ -102,17 +102,27 @@ public class GroovyUtil {
 
     public static Class<?> getScriptClassFromLocation(String location) throws GeneralException {
         try {
-            Class<?> scriptClass = parsedScripts.get(location);
+            Class<?> scriptClass = null;
+            synchronized (parsedScripts) {
+                scriptClass = parsedScripts.get(location);
+            }
             if (scriptClass == null) {
                 URL scriptUrl = FlexibleLocation.resolveLocation(location);
                 if (scriptUrl == null) {
                     throw new GeneralException("Script not found at location [" + location + "]");
                 }
                 scriptClass = parseClass(scriptUrl.openStream(), location);
-                if (Debug.verboseOn()) {
-                    Debug.logVerbose("Caching Groovy script at: " + location, module);
+                synchronized (parsedScripts) {
+                    Class<?> scriptClassCached = parsedScripts.get(location);
+                    if (scriptClassCached == null) {
+                        if (Debug.verboseOn()) {
+                            Debug.logVerbose("Caching Groovy script at: " + location, module);
+                        }
+                        parsedScripts.put(location, scriptClass);
+                    } else {
+                        scriptClass = scriptClassCached;
+                    }
                 }
-                parsedScripts.put(location, scriptClass);
             }
             return scriptClass;
         } catch (Exception e) {
@@ -142,13 +152,24 @@ public class GroovyUtil {
 
     public static Object runScriptFromClasspath(String script, Map<String,Object> context) throws GeneralException {
         try {
-            Class<?> scriptClass = parsedScripts.get(script);
+            Class<?> scriptClass = null;
+            synchronized (parsedScripts) {
+                parsedScripts.get(script);
+            }
             if (scriptClass == null) {
                 scriptClass = loadClass(script);
-                if (Debug.verboseOn()) Debug.logVerbose("Caching Groovy script: " + script, module);
-                parsedScripts.put(script, scriptClass);
+                synchronized (parsedScripts) {
+                    Class<?> scriptClassCached = parsedScripts.get(script);
+                    if (scriptClassCached == null) {
+                        if (Debug.verboseOn()) {
+                            Debug.logVerbose("Caching Groovy script: " + script, module);
+                        }
+                        parsedScripts.put(script, scriptClass);
+                    } else {
+                        scriptClass = scriptClassCached;
+                    }
+                }
             }
-
             return InvokerHelper.createScript(scriptClass, getBinding(context)).run();
         } catch (CompilationFailedException e) {
             String errMsg = "Error loading Groovy script [" + script + "]: " + e.toString();

Modified: ofbiz/branches/release10.04/themes/bizznesstime/includes/footer.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/themes/bizznesstime/includes/footer.ftl?rev=1332526&r1=1332525&r2=1332526&view=diff
==============================================================================
--- ofbiz/branches/release10.04/themes/bizznesstime/includes/footer.ftl (original)
+++ ofbiz/branches/release10.04/themes/bizznesstime/includes/footer.ftl Tue May  1 05:30:31 2012
@@ -25,7 +25,7 @@ under the License.
 </div>
 <!-- footer -->
 <div id="footer">
-    <div class="poweredBy"><span>Powered by <a href="http://ofbiz.apache.org" class="noicon">OFBiz</a></span><span>Copyright 2001-2009 <a href="http://www.apache.org" class="noicon">The Apache Software Foundation - www.apache.org</a></span><span><#include "../../../runtime/svninfo.ftl" /></span></div>
+    <div class="poweredBy"><span>Powered by <a href="http://ofbiz.apache.org" class="noicon">OFBiz</a></span><span>Copyright 2001-2009 <a href="http://www.apache.org" class="noicon">The Apache Software Foundation - www.apache.org</a></span><span><#include "ofbizhome://runtime/svninfo.ftl" /></span></div>
 
 </div>
 <!-- footer -->

Modified: ofbiz/branches/release10.04/themes/droppingcrumbs/includes/footer.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/themes/droppingcrumbs/includes/footer.ftl?rev=1332526&r1=1332525&r2=1332526&view=diff
==============================================================================
--- ofbiz/branches/release10.04/themes/droppingcrumbs/includes/footer.ftl (original)
+++ ofbiz/branches/release10.04/themes/droppingcrumbs/includes/footer.ftl Tue May  1 05:30:31 2012
@@ -27,7 +27,7 @@ under the License.
   <a href="http://validator.w3.org/check?uri=referer"><img src="<@o...@ofbizContentUrl>" alt="Valid XHTML 1.0!"/></a></p>
   <p>
   ${uiLabelMap.CommonCopyright} (c) 2001-${nowTimestamp?string("yyyy")} The Apache Software Foundation - <a href="http://www.apache.org" target="_blank">www.apache.org</a><br />
-  ${uiLabelMap.CommonPoweredBy} <a href="http://ofbiz.apache.org" target="_blank">Apache OFBiz</a> <#include "../../../runtime/svninfo.ftl" /></p>
+  ${uiLabelMap.CommonPoweredBy} <a href="http://ofbiz.apache.org" target="_blank">Apache OFBiz</a> <#include "ofbizhome://runtime/svninfo.ftl" /></p>
 </div>
 <#if layoutSettings.VT_FTR_JAVASCRIPT?has_content>
   <#list layoutSettings.VT_FTR_JAVASCRIPT as javaScript>

Modified: ofbiz/branches/release10.04/themes/flatgrey/includes/footer.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/themes/flatgrey/includes/footer.ftl?rev=1332526&r1=1332525&r2=1332526&view=diff
==============================================================================
--- ofbiz/branches/release10.04/themes/flatgrey/includes/footer.ftl (original)
+++ ofbiz/branches/release10.04/themes/flatgrey/includes/footer.ftl Tue May  1 05:30:31 2012
@@ -62,7 +62,7 @@ under the License.
   <a href="http://validator.w3.org/check?uri=referer"><img src="<@o...@ofbizContentUrl>" alt="Valid XHTML 1.0!"/></a></p>
   <p>
   ${uiLabelMap.CommonCopyright} (c) 2001-${nowTimestamp?string("yyyy")} The Apache Software Foundation - <a href="http://www.apache.org" target="_blank">www.apache.org</a><br />
-  ${uiLabelMap.CommonPoweredBy} <a href="http://ofbiz.apache.org" target="_blank">Apache OFBiz</a> <#include "../../../runtime/svninfo.ftl" /></p>
+  ${uiLabelMap.CommonPoweredBy} <a href="http://ofbiz.apache.org" target="_blank">Apache OFBiz</a> <#include "ofbizhome://runtime/svninfo.ftl" /></p>
 </div>
 <#if layoutSettings.VT_FTR_JAVASCRIPT?has_content>
   <#list layoutSettings.VT_FTR_JAVASCRIPT as javaScript>

Modified: ofbiz/branches/release10.04/themes/tomahawk/includes/footer.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/themes/tomahawk/includes/footer.ftl?rev=1332526&r1=1332525&r2=1332526&view=diff
==============================================================================
--- ofbiz/branches/release10.04/themes/tomahawk/includes/footer.ftl (original)
+++ ofbiz/branches/release10.04/themes/tomahawk/includes/footer.ftl Tue May  1 05:30:31 2012
@@ -23,7 +23,7 @@ under the License.
   <ul>
     <li>
       ${uiLabelMap.CommonCopyright} (c) 2001-${nowTimestamp?string("yyyy")} The Apache Software Foundation - <a href="http://www.apache.org" target="_blank">www.apache.org</a><br/>
-      ${uiLabelMap.CommonPoweredBy} <a href="http://ofbiz.apache.org" target="_blank">Apache OFBiz</a> <#include "../../../runtime/svninfo.ftl" />
+      ${uiLabelMap.CommonPoweredBy} <a href="http://ofbiz.apache.org" target="_blank">Apache OFBiz</a> <#include "ofbizhome://runtime/svninfo.ftl" />
     </li>
     <li class="opposed">${nowTimestamp?datetime?string.short} -
   <a href="<@o...@ofbizUrl>">${timeZone.getDisplayName(timeZone.useDaylightTime(), Static["java.util.TimeZone"].LONG, locale)}</a>