myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: refactored
Date Tue, 13 Aug 2019 15:06:19 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new 93769ad  refactored
93769ad is described below

commit 93769ad3d68d4583e4146360f9a146382d9a63c3
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Tue Aug 13 17:06:12 2019 +0200

    refactored
---
 .../myfaces/application/ApplicationImpl.java       | 23 ++++++++--------------
 .../apache/myfaces/application/ViewIdSupport.java  | 12 +++--------
 .../viewstate/StateCacheServerSide.java            |  9 ++-------
 .../cdi/view/ViewScopeContextualStorage.java       |  2 +-
 .../org/apache/myfaces/config/LogMetaInfUtils.java |  7 +------
 5 files changed, 15 insertions(+), 38 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java b/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
index 58713ab..c7e6088 100755
--- a/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
@@ -2512,7 +2512,7 @@ public class ApplicationImpl extends Application
                  * 
                  * Registrations found:
                  */
-                _lstSystemEventListener = new CopyOnWriteArrayList<SystemEventListener>();
+                _lstSystemEventListener = new CopyOnWriteArrayList<>();
             }
 
             return _lstSystemEventListener;
@@ -2522,22 +2522,15 @@ public class ApplicationImpl extends Application
         {
             if (_sourceClassMap == null)
             {
-                _sourceClassMap = new ConcurrentHashMap<Class<?>, List<SystemEventListener>>();
+                _sourceClassMap = new ConcurrentHashMap<>();
             }
 
-            List<SystemEventListener> list = _sourceClassMap.get(sourceClass);
-            if (list == null)
-            {
-                /*
-                 * TODO: Check if modification occurs often or not, might have to use a synchronized
list instead.
-                 * 
-                 * Registrations found:
-                 */
-                list = new CopyOnWriteArrayList<SystemEventListener>();
-                _sourceClassMap.put(sourceClass, list);
-            }
-
-            return list;
+            /*
+             * TODO: Check if modification occurs often or not, might have to use a synchronized
list instead.
+             * 
+             * Registrations found:
+             */
+            return _sourceClassMap.computeIfAbsent(sourceClass, k -> new CopyOnWriteArrayList<>());
         }
     }
     
diff --git a/impl/src/main/java/org/apache/myfaces/application/ViewIdSupport.java b/impl/src/main/java/org/apache/myfaces/application/ViewIdSupport.java
index 876a4dc..0581deb 100644
--- a/impl/src/main/java/org/apache/myfaces/application/ViewIdSupport.java
+++ b/impl/src/main/java/org/apache/myfaces/application/ViewIdSupport.java
@@ -67,15 +67,9 @@ public class ViewIdSupport
 
     public static ViewIdSupport getInstance(FacesContext facesContext)
     {
-        ViewIdSupport instance = (ViewIdSupport)
-                facesContext.getExternalContext().getApplicationMap().get(INSTANCE_KEY);
-        if (instance == null)
-        {
-            instance = new ViewIdSupport(facesContext);
-            facesContext.getExternalContext().getApplicationMap().put(INSTANCE_KEY, instance);
-        }
-
-        return instance;
+        return (ViewIdSupport)
+                facesContext.getExternalContext().getApplicationMap().computeIfAbsent(INSTANCE_KEY,
+                        k -> new ViewIdSupport(facesContext));
     }
     
     protected ViewIdSupport(FacesContext facesContext)
diff --git a/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheServerSide.java
b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheServerSide.java
index 03b2c46..6d9a407 100644
--- a/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheServerSide.java
+++ b/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheServerSide.java
@@ -138,13 +138,8 @@ class StateCacheServerSide extends StateCache<Object, Object>
     protected void saveSerializedViewInServletSession(FacesContext context, Object serializedView)
     {
         Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
-        SerializedViewCollection viewCollection = (SerializedViewCollection) sessionMap
-                .get(SERIALIZED_VIEW_SESSION_ATTR);
-        if (viewCollection == null)
-        {
-            viewCollection = sessionViewStorageFactory.createSerializedViewCollection(context);
-            sessionMap.put(SERIALIZED_VIEW_SESSION_ATTR, viewCollection);
-        }
+        SerializedViewCollection viewCollection = (SerializedViewCollection) sessionMap.computeIfAbsent(
+                SERIALIZED_VIEW_SESSION_ATTR, k -> sessionViewStorageFactory.createSerializedViewCollection(context));
 
         Map<Object,Object> attributeMap = context.getAttributes();
         
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorage.java
b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorage.java
index 384d849..ba73586 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorage.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorage.java
@@ -88,7 +88,7 @@ public class ViewScopeContextualStorage implements Serializable
         instanceInfo.setContextualInstance(bean.create(creationalContext));
 
         contextualInstances.put(beanKey, instanceInfo);
-        if(bean instanceof Bean)
+        if (bean instanceof Bean)
         {
             String name = ((Bean<T>) bean).getName();
             if (name != null)
diff --git a/impl/src/main/java/org/apache/myfaces/config/LogMetaInfUtils.java b/impl/src/main/java/org/apache/myfaces/config/LogMetaInfUtils.java
index c2d8e26..af45d64 100644
--- a/impl/src/main/java/org/apache/myfaces/config/LogMetaInfUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/config/LogMetaInfUtils.java
@@ -143,12 +143,7 @@ class LogMetaInfUtils
         {
             // We have a valid JAR
             String artifactId = matcher.group(REGEX_LIBRARY_ARTIFACT_ID);
-            List<JarInfo> versions = libs.get(artifactId);
-            if (versions == null)
-            {
-                versions = new ArrayList<JarInfo>(1);
-                libs.put(artifactId, versions);
-            }
+            List<JarInfo> versions = libs.computeIfAbsent(artifactId, k -> new ArrayList<>(1));
 
             String path = matcher.group(REGEX_LIBRARY_FILE_PATH);
 


Mime
View raw message