You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2020/05/11 12:55:57 UTC

[struts] 02/02: Reduces noise in the logs

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

lukaszlenart pushed a commit to branch tiny-improvments
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 035c8b14b780d320910e0671b60e77c61a1eb96c
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Mon May 11 14:55:44 2020 +0200

    Reduces noise in the logs
---
 core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
index 21bc0fc..c66d5c9 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
@@ -40,6 +40,7 @@ import java.lang.reflect.Method;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Pattern;
 
 
@@ -53,6 +54,9 @@ public class OgnlUtil {
 
     private static final Logger LOG = LogManager.getLogger(OgnlUtil.class);
 
+    // Flag used to reduce flooding logs with WARNs about using DevMode excluded packages
+    private final AtomicBoolean warnReported = new AtomicBoolean(false);
+
     private final ConcurrentMap<String, Object> expressions = new ConcurrentHashMap<>();
     private final ConcurrentMap<Class<?>, BeanInfo> beanInfoCache = new ConcurrentHashMap<>();
     private TypeConverter defaultConverter;
@@ -806,7 +810,10 @@ public class OgnlUtil {
         memberAccess.setDisallowProxyMemberAccess(disallowProxyMemberAccess);
 
         if (devMode) {
-            LOG.warn("Working in devMode, using devMode excluded classes and packages!");
+            if (!warnReported.get()) {
+                warnReported.set(true);
+                LOG.warn("Working in devMode, using devMode excluded classes and packages!");
+            }
             memberAccess.setExcludedClasses(devModeExcludedClasses);
             memberAccess.setExcludedPackageNamePatterns(devModeExcludedPackageNamePatterns);
             memberAccess.setExcludedPackageNames(devModeExcludedPackageNames);