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

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


The following commit(s) were added to refs/heads/trunk by this push:
     new 185569c  Fixed: Fix some bugs Spotbugs reports (OFBIZ-12386)
185569c is described below

commit 185569c8aa990704594618179036fba98f452578
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Wed Nov 17 16:23:19 2021 +0100

    Fixed: Fix some bugs Spotbugs reports (OFBIZ-12386)
    
    Incorrect lazy initialisation
    
    Thanks: Spotbugs
---
 .../java/org/apache/ofbiz/base/util/UtilHtml.java  | 41 ++++++++++------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git 
a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHtml.java 
b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHtml.java
index 44bfe15..2acea90 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHtml.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHtml.java
@@ -44,7 +44,7 @@ public final class UtilHtml {
     private static final String MODULE = UtilHtml.class.getName();
     private static final Parser JSOUP_HTML_PARSER = createJSoupHtmlParser();
     private static final String[] TAG_SHOULD_CLOSE_LIST = new String[]{"div"};
-    private static List<String> visualThemeBasePathsName;
+    private static List<String> visualThemeBasePathsName = new ArrayList<>();
     private UtilHtml() { }
 
     private static Parser createJSoupHtmlParser() {
@@ -117,29 +117,26 @@ public final class UtilHtml {
     }
 
     public static List<String> getVisualThemeFolderNamesToExempt() {
-        if (visualThemeBasePathsName == null) {
-            try {
-                List<File> xmlThemes = ThemeFactory.getThemeXmlFiles();
-                visualThemeBasePathsName = new ArrayList<>();
-                String themePathKey = "/themes/";
-                String pluginPathKey = "/plugins/";
-                for (File xmlTheme : xmlThemes) {
-                    String path = xmlTheme.toURI().toURL().toString();
-                    // get the path after themes or plugins folders
-                    if (path.indexOf(themePathKey) > 0) {
-                        path = path.substring(path.indexOf(themePathKey) + 8);
-                    } else if (path.indexOf(pluginPathKey) > 0) {
-                        path = path.substring(path.indexOf(pluginPathKey) + 9);
-                    }
-                    // get folder name
-                    path = path.substring(0, path.indexOf("/"));
-                    if (!path.contains("common-theme") && 
!path.contains("ecommerce")) {
-                        visualThemeBasePathsName.add("/" + path + "/");
-                    }
+        try {
+            List<File> xmlThemes = ThemeFactory.getThemeXmlFiles();
+            String themePathKey = "/themes/";
+            String pluginPathKey = "/plugins/";
+            for (File xmlTheme : xmlThemes) {
+                String path = xmlTheme.toURI().toURL().toString();
+                // get the path after themes or plugins folders
+                if (path.indexOf(themePathKey) > 0) {
+                    path = path.substring(path.indexOf(themePathKey) + 8);
+                } else if (path.indexOf(pluginPathKey) > 0) {
+                    path = path.substring(path.indexOf(pluginPathKey) + 9);
+                }
+                // get folder name
+                path = path.substring(0, path.indexOf("/"));
+                if (!path.contains("common-theme") && 
!path.contains("ecommerce")) {
+                    visualThemeBasePathsName.add("/" + path + "/");
                 }
-            } catch (IOException e) {
-                Debug.logError(e, MODULE);
             }
+        } catch (IOException e) {
+            Debug.logError(e, MODULE);
         }
         return Collections.unmodifiableList(visualThemeBasePathsName);
     }

Reply via email to