[ofbiz-framework] branch release18.12 updated: Fixed: webtools/control/threadList no longer works on trunk (only) (OFBIZ-12195)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch release18.12 updated: Fixed: webtools/control/threadList no longer works on trunk (only) (OFBIZ-12195)

jleroux@apache.org
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release18.12 by this push:
     new 82c2258  Fixed: webtools/control/threadList no longer works on trunk (only) (OFBIZ-12195)
82c2258 is described below

commit 82c225824785819e5e66b92f6f00d9306e1f620b
Author: Jacques Le Roux <[hidden email]>
AuthorDate: Fri Mar 12 08:57:41 2021 +0100

    Fixed: webtools/control/threadList no longer works on trunk (only) (OFBIZ-12195)
   
    It works if we downgrade Freemarker to 2.3.28 as in R18 and even using 2.3.29,
    not 2.3.30.
   
    Handles things at the Groovy level, ie put in context, rather than creating
    in Freemarker template.
   
    It's backported, even if it's not a pb but in trunk, because it's a (low)
    security issue.
---
 framework/webtools/groovyScripts/service/Threads.groovy | 9 +++++++++
 framework/webtools/template/service/Threads.ftl         | 4 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/framework/webtools/groovyScripts/service/Threads.groovy b/framework/webtools/groovyScripts/service/Threads.groovy
index b65f40f..fb222da 100644
--- a/framework/webtools/groovyScripts/service/Threads.groovy
+++ b/framework/webtools/groovyScripts/service/Threads.groovy
@@ -50,4 +50,13 @@ Thread[] allThreadArray = new Thread[1000]
 topThreadGroup.enumerate(allThreadArray)
 allThreadList = Arrays.asList(allThreadArray)
 
+allThreadStackTrace = [:]
+for (thread in allThreadList) {
+    if (thread) {
+        allThreadStackTrace.put(thread.getName(), thread.getStackTrace())
+    }
+}
+
+context.currentThread = currentThread
+context.allThreadStackTrace = allThreadStackTrace
 context.allThreadList = allThreadList
diff --git a/framework/webtools/template/service/Threads.ftl b/framework/webtools/template/service/Threads.ftl
index ff80f6e..0fc3c3f 100644
--- a/framework/webtools/template/service/Threads.ftl
+++ b/framework/webtools/template/service/Threads.ftl
@@ -18,7 +18,7 @@ under the License.
 -->
 <#if parameters.maxElements?has_content><#assign maxElements = parameters.maxElements?number/><#else><#assign maxElements = 10/></#if>
 
-    <p>${uiLabelMap.WebtoolsThisThread}<b> ${Static["java.lang.Thread"].currentThread().getName()} (${Static["java.lang.Thread"].currentThread().getId()})</b></p>
+    <p>${uiLabelMap.WebtoolsThisThread}<b> ${currentThread.getName()} (${currentThread.getId()})</b></p>
     <br />
     <table class="basic-table hover-bar" cellspacing="0">
       <tr class="header-row">
@@ -32,7 +32,7 @@ under the License.
       <#assign alt_row = false>
       <#list allThreadList as javaThread>
       <#if javaThread??>
-        <#assign stackTraceArray = javaThread.getStackTrace()/>
+        <#assign stackTraceArray = allThreadStackTrace.get(javaThread.getName())/>
         <tr valign="middle"<#if alt_row> class="alternate-row"</#if>>
           <td valign="top">${(javaThread.getThreadGroup().getName())!}</td>
           <td valign="top">${javaThread.getId()?string}</td>