You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by dg...@apache.org on 2022/08/30 08:51:47 UTC

[unomi] branch fix-groovy-actions-concurrency-issues created (now b3e4feb12)

This is an automated email from the ASF dual-hosted git repository.

dgriffon pushed a change to branch fix-groovy-actions-concurrency-issues
in repository https://gitbox.apache.org/repos/asf/unomi.git


      at b3e4feb12 UNOMI-652 : fix concurrency issue while loading groovy actions

This branch includes the following new commits:

     new b3e4feb12 UNOMI-652 : fix concurrency issue while loading groovy actions

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[unomi] 01/01: UNOMI-652 : fix concurrency issue while loading groovy actions

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

dgriffon pushed a commit to branch fix-groovy-actions-concurrency-issues
in repository https://gitbox.apache.org/repos/asf/unomi.git

commit b3e4feb12519a15cf75a1e5ac6137be660aadbc5
Author: David Griffon <dg...@jahia.com>
AuthorDate: Tue Aug 30 10:51:07 2022 +0200

    UNOMI-652 : fix concurrency issue while loading groovy actions
---
 .../groovy/actions/services/impl/GroovyActionsServiceImpl.java   | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java
index fc2f62c1f..b72a089b4 100644
--- a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java
+++ b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java
@@ -131,7 +131,7 @@ public class GroovyActionsServiceImpl implements GroovyActionsService {
         logger.info("Groovy action service initialized.");
     }
 
-    public void onDestroy(){
+    public void onDestroy() {
         logger.debug("onDestroy Method called");
         scheduledFuture.cancel(true);
     }
@@ -251,11 +251,12 @@ public class GroovyActionsServiceImpl implements GroovyActionsService {
     }
 
     private void refreshGroovyActions() {
+        Map<String, GroovyCodeSource> refreshedGroovyCodeSourceMap = new HashMap<>();
         GroovyCodeSource baseScript = groovyCodeSourceMap.get(BASE_SCRIPT_NAME);
-        groovyCodeSourceMap = new HashMap<>();
-        groovyCodeSourceMap.put(BASE_SCRIPT_NAME, baseScript);
-        persistenceService.getAllItems(GroovyAction.class).forEach(groovyAction -> groovyCodeSourceMap
+        refreshedGroovyCodeSourceMap.put(BASE_SCRIPT_NAME, baseScript);
+        persistenceService.getAllItems(GroovyAction.class).forEach(groovyAction -> refreshedGroovyCodeSourceMap
                 .put(groovyAction.getName(), buildClassScript(groovyAction.getScript(), groovyAction.getName())));
+        groovyCodeSourceMap = refreshedGroovyCodeSourceMap;
     }
 
     private void initializeTimers() {