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 Mon, 12 Aug 2019 15:38:42 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 f63f242  refactored
f63f242 is described below

commit f63f242b2ce2dfef1bab01d5e163ba0215a4a6a9
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Mon Aug 12 17:38:34 2019 +0200

    refactored
---
 .../apache/myfaces/cdi/FacesScopeBeanHolder.java   | 19 +++++------------
 .../myfaces/cdi/view/ViewScopeBeanHolder.java      | 15 +-------------
 .../myfaces/cdi/view/ViewScopeContextImpl.java     | 13 +++---------
 .../cdi/view/ViewTransientScopeBeanHolder.java     |  9 +++-----
 .../org/apache/myfaces/config/MyfacesConfig.java   | 10 ++-------
 .../org/apache/myfaces/config/RuntimeConfig.java   | 24 ++++------------------
 .../annotation/CdiAnnotationProviderExtension.java |  8 +-------
 .../annotation/DefaultAnnotationProvider.java      | 14 ++-----------
 .../myfaces/config/impl/elements/RedirectImpl.java |  8 +-------
 .../myfaces/context/RequestViewMetadata.java       | 15 +++-----------
 .../myfaces/context/servlet/FacesContextImpl.java  | 11 +++-------
 .../servlet/ServletExternalContextImpl.java        | 13 ++++--------
 .../el/resolver/ImportConstantsELResolver.java     |  9 ++------
 .../org/apache/myfaces/flow/FlowHandlerImpl.java   | 24 ++++++----------------
 .../java/org/apache/myfaces/flow/FlowImpl.java     | 18 ++++++----------
 .../myfaces/flow/cdi/FlowScopeBeanHolder.java      | 14 +++++--------
 .../myfaces/flow/cdi/FlowScopedContextImpl.java    | 17 ++++-----------
 .../view/facelets/tag/jsf/FaceletState.java        | 11 ++++------
 18 files changed, 59 insertions(+), 193 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeBeanHolder.java b/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeBeanHolder.java
index 64aebe1..bf3f624 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeBeanHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeBeanHolder.java
@@ -52,14 +52,8 @@ public class FacesScopeBeanHolder
      */
     public ContextualStorage getContextualStorage(BeanManager beanManager, FacesContext facesContext)
     {
-        ContextualStorage contextualStorage = (ContextualStorage) facesContext.getAttributes().get(FACES_SCOPE_MAP);
-        if (contextualStorage == null)
-        {
-            contextualStorage = new ContextualStorage(beanManager, false, false);
-            facesContext.getAttributes().put(FACES_SCOPE_MAP, contextualStorage);
-        }
-
-        return contextualStorage;
+        return (ContextualStorage) facesContext.getAttributes().computeIfAbsent(FACES_SCOPE_MAP,
+                k -> new ContextualStorage(beanManager, false, false));
     }
     
     public ContextualStorage getContextualStorageNoCreate(BeanManager beanManager, FacesContext
facesContext)
@@ -73,12 +67,9 @@ public class FacesScopeBeanHolder
         if (create)
         {
             ContextualStorage contextualStorage = getContextualStorage(beanManager, facesContext);
-            ContextualInstanceInfo info = contextualStorage.getStorage().get(FACES_SCOPE_MAP_INFO);
-            if (info == null)
-            {
-                info = new ContextualInstanceInfo<Object>();
-                contextualStorage.getStorage().put(FACES_SCOPE_MAP_INFO, info);
-            }
+            ContextualInstanceInfo info = contextualStorage.getStorage().computeIfAbsent(FACES_SCOPE_MAP_INFO,
+                    k -> new ContextualInstanceInfo<>());
+
             map = (Map<Object, Object>) info.getContextualInstance();
             if (map == null)
             {
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java
index 1025433..5aa67fa 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java
@@ -82,20 +82,7 @@ public class ViewScopeBeanHolder implements Serializable
      */
     public ViewScopeContextualStorage getContextualStorage(BeanManager beanManager, String
viewScopeId)
     {
-        ViewScopeContextualStorage contextualStorage = storageMap.get(viewScopeId);
-        if (contextualStorage == null)
-        {
-            synchronized (this)
-            {            
-                contextualStorage = storageMap.get(viewScopeId);
-                if (contextualStorage == null)
-                {
-                    contextualStorage = new ViewScopeContextualStorage(beanManager);
-                    storageMap.put(viewScopeId, contextualStorage);
-                }
-            }
-        }
-        return contextualStorage;
+        return storageMap.computeIfAbsent(viewScopeId, k -> new ViewScopeContextualStorage(beanManager));
     }
 
     public Map<String, ViewScopeContextualStorage> getStorageMap()
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java
index 60b273a..38b6dd3 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java
@@ -73,16 +73,9 @@ public class ViewScopeContextImpl implements Context
     
     protected ViewScopeBeanHolder getViewScopeBeanHolder(FacesContext facesContext)
     {
-        ViewScopeBeanHolder viewScopeBeanHolder = (ViewScopeBeanHolder) 
-            facesContext.getExternalContext().getApplicationMap().get(
-                "oam.view.ViewScopeBeanHolder");
-        if (viewScopeBeanHolder == null)
-        {
-            viewScopeBeanHolder = CDIUtils.get(beanManager, ViewScopeBeanHolder.class);
-            facesContext.getExternalContext().getApplicationMap().put(
-                "oam.view.ViewScopeBeanHolder", viewScopeBeanHolder);
-        }
-        return viewScopeBeanHolder;
+        return (ViewScopeBeanHolder)facesContext.getExternalContext().getApplicationMap().computeIfAbsent(
+                "oam.view.ViewScopeBeanHolder",
+                k -> CDIUtils.get(beanManager, ViewScopeBeanHolder.class));
     }
 
     public String getCurrentViewScopeId(boolean create)
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeBeanHolder.java
b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeBeanHolder.java
index 1b87a0a..0d8f14a 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeBeanHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeBeanHolder.java
@@ -69,12 +69,9 @@ public class ViewTransientScopeBeanHolder
         if (create)
         {
             ContextualStorage contextualStorage = getContextualStorage(beanManager, facesContext);
-            ContextualInstanceInfo info = contextualStorage.getStorage().get(VIEW_TRANSIENT_SCOPE_MAP_INFO);
-            if (info == null)
-            {
-                info = new ContextualInstanceInfo<>();
-                contextualStorage.getStorage().put(VIEW_TRANSIENT_SCOPE_MAP_INFO, info);
-            }
+            ContextualInstanceInfo info = contextualStorage.getStorage().computeIfAbsent(VIEW_TRANSIENT_SCOPE_MAP_INFO,
+                    k -> new ContextualInstanceInfo<>());
+
             map = (Map<Object, Object>) info.getContextualInstance();
             if (map == null)
             {
diff --git a/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java b/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java
index 4920e0c..ace25c1 100755
--- a/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java
+++ b/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java
@@ -945,14 +945,8 @@ public class MyfacesConfig
     
     public static MyfacesConfig getCurrentInstance(ExternalContext extCtx)
     {
-        MyfacesConfig myfacesConfig = (MyfacesConfig) extCtx.getApplicationMap().get(APPLICATION_MAP_PARAM_NAME);
-        if (myfacesConfig == null)
-        {
-            myfacesConfig = createAndInitializeMyFacesConfig(extCtx);
-            extCtx.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, myfacesConfig);
-        }
-
-        return myfacesConfig;
+        return (MyfacesConfig) extCtx.getApplicationMap().computeIfAbsent(
+                APPLICATION_MAP_PARAM_NAME, k -> createAndInitializeMyFacesConfig(extCtx));
     }
     
     public MyfacesConfig()
diff --git a/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java b/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
index d7b7e32..9ec8bbe 100755
--- a/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
+++ b/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
@@ -126,14 +126,8 @@ public class RuntimeConfig
     
     public static RuntimeConfig getCurrentInstance(ExternalContext externalContext)
     {
-        RuntimeConfig runtimeConfig = (RuntimeConfig) externalContext.getApplicationMap().get(
-                APPLICATION_MAP_PARAM_NAME);
-        if (runtimeConfig == null)
-        {
-            runtimeConfig = new RuntimeConfig();
-            externalContext.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, runtimeConfig);
-        }
-        return runtimeConfig;
+        return (RuntimeConfig) externalContext.getApplicationMap().computeIfAbsent(
+                APPLICATION_MAP_PARAM_NAME, k -> new RuntimeConfig());
     }
 
     public void purge()
@@ -418,23 +412,13 @@ public class RuntimeConfig
 
     public void addContractMapping(String urlPattern, String[] contracts)
     {
-        List<String> contractsList = _contractMappings.get(urlPattern);
-        if (contractsList == null)
-        {
-            contractsList = new ArrayList<String>();
-            _contractMappings.put(urlPattern, contractsList);
-        }
+        List<String> contractsList = _contractMappings.computeIfAbsent(urlPattern,
k -> new ArrayList<>());
         Collections.addAll(contractsList, contracts);
     }
     
     public void addContractMapping(String urlPattern, String contract)
     {
-        List<String> contractsList = _contractMappings.get(urlPattern);
-        if (contractsList == null)
-        {
-            contractsList = new ArrayList<String>();
-            _contractMappings.put(urlPattern, contractsList);
-        }
+        List<String> contractsList = _contractMappings.computeIfAbsent(urlPattern,
k -> new ArrayList<>());
         contractsList.add(contract);
     }    
     
diff --git a/impl/src/main/java/org/apache/myfaces/config/annotation/CdiAnnotationProviderExtension.java
b/impl/src/main/java/org/apache/myfaces/config/annotation/CdiAnnotationProviderExtension.java
index 52af60f..83355f5 100644
--- a/impl/src/main/java/org/apache/myfaces/config/annotation/CdiAnnotationProviderExtension.java
+++ b/impl/src/main/java/org/apache/myfaces/config/annotation/CdiAnnotationProviderExtension.java
@@ -64,13 +64,7 @@ public class CdiAnnotationProviderExtension implements Extension
         {
             if (type.isAnnotationPresent(annotation))
             {
-                Set<Class<?>> set = map.get(annotation);
-                if (set == null)
-                {
-                    set = new HashSet<>();
-                    map.put(annotation, set);
-                }
-
+                Set<Class<?>> set = map.computeIfAbsent(annotation, k -> new
HashSet<>());
                 set.add(type.getJavaClass());
             }
         }
diff --git a/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
b/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
index fee815b..2368d86 100644
--- a/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
+++ b/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
@@ -692,18 +692,8 @@ public class DefaultAnnotationProvider extends AnnotationProvider
             Class<? extends Annotation> annotationClass = anno.annotationType();
             if (JSF_ANNOTATION_CLASSES.contains(annotationClass))
             {
-                Set<Class<?>> set = map.get(annotationClass);
-                if (set == null)
-                {
-                    set = new HashSet<Class<?>>();
-                    set.add(clazz);
-                    map.put(annotationClass, set);
-                }
-                else
-                {
-                    set.add(clazz);
-                }
-
+                Set<Class<?>> set = map.computeIfAbsent(annotationClass, k ->
new HashSet<>());
+                set.add(clazz);
             }
         }
     }
diff --git a/impl/src/main/java/org/apache/myfaces/config/impl/elements/RedirectImpl.java
b/impl/src/main/java/org/apache/myfaces/config/impl/elements/RedirectImpl.java
index 56d0079..398047a 100644
--- a/impl/src/main/java/org/apache/myfaces/config/impl/elements/RedirectImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/config/impl/elements/RedirectImpl.java
@@ -32,14 +32,8 @@ public class RedirectImpl extends org.apache.myfaces.config.element.Redirect
imp
     
     public void addViewParam(ViewParamImpl viewParam)
     {
-        List<String> params = viewParams.get(viewParam.getName());
-        if(params == null)
-        {
-            params = new ArrayList<String>();
-        }
-
+        List<String> params = viewParams.computeIfAbsent(viewParam.getName(), k ->
new ArrayList<String>());
         params.add(viewParam.getValue());
-        viewParams.put(viewParam.getName(), params);
     }
     
     @Override
diff --git a/impl/src/main/java/org/apache/myfaces/context/RequestViewMetadata.java b/impl/src/main/java/org/apache/myfaces/context/RequestViewMetadata.java
index c7c1204..5e7eea0 100644
--- a/impl/src/main/java/org/apache/myfaces/context/RequestViewMetadata.java
+++ b/impl/src/main/java/org/apache/myfaces/context/RequestViewMetadata.java
@@ -137,12 +137,8 @@ public class RequestViewMetadata implements Serializable
                 {
                     target = "head";
                 }
-                List<ResourceDependency> list = map.get(target);
-                if (list == null)
-                {
-                    list = new ArrayList<>();
-                    map.put(target, list);
-                }
+
+                List<ResourceDependency> list = map.computeIfAbsent(target, k ->
new ArrayList<>());
                 list.add(annotation);
             }
         }
@@ -161,12 +157,7 @@ public class RequestViewMetadata implements Serializable
                     target = "head";
                 }
 
-                List<ResourceDependency> list = map.get(target);
-                if (list == null)
-                {
-                    list = new ArrayList<>();
-                    map.put(target, list);
-                }
+                List<ResourceDependency> list = map.computeIfAbsent(target, k ->
new ArrayList<>());
                 list.add(annotation);
             }
         }
diff --git a/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java b/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java
index d743fb4..468d4a8 100755
--- a/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java
@@ -178,15 +178,10 @@ public class FacesContextImpl extends FacesContextImplBase
             _orderedMessages = new ArrayList<>();
         }
         
-        List<FacesMessage> lst = _messages.get(clientId); 
-        if (lst == null)
-        {
-            lst = new ArrayList<>();
-            _messages.put(clientId, lst);
-        }
-        
+        List<FacesMessage> lst = _messages.computeIfAbsent(clientId, k -> new ArrayList<>());
        
         lst.add(message);
-        _orderedMessages.add (message);
+
+        _orderedMessages.add(message);
         
         FacesMessage.Severity serSeverity = message.getSeverity();
         if (serSeverity != null)
diff --git a/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
b/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
index da77285..292def5 100755
--- a/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
@@ -889,13 +889,8 @@ public final class ServletExternalContextImpl extends ServletExternalContextImpl
                     paramMap = new HashMap<String, List<String>>();
                 }
                 
-                List<String> values = paramMap.get(currentName);
-                if (values == null)
-                {
-                    values = new ArrayList<>(1);
-                    paramMap.put(currentName, values);
-                }
- 
+                List<String> values = paramMap.computeIfAbsent(currentName, k ->
new ArrayList<>(1));
+
                 try
                 {
                     values.add(currentPair.length > 1
@@ -921,7 +916,7 @@ public final class ServletExternalContextImpl extends ServletExternalContextImpl
                 {
                     if (paramMap == null)
                     {
-                        paramMap = new HashMap<String, List<String>>();
+                        paramMap = new HashMap<>();
                     }
                     paramMap.put(key, pair.getValue());
                 }
@@ -943,7 +938,7 @@ public final class ServletExternalContextImpl extends ServletExternalContextImpl
                         value.add(entry.getValue());
                         if (paramMap == null)
                         {
-                            paramMap = new HashMap<String, List<String>>();
+                            paramMap = new HashMap<>();
                         }
                         paramMap.put(entry.getKey(), value);
                     }
diff --git a/impl/src/main/java/org/apache/myfaces/el/resolver/ImportConstantsELResolver.java
b/impl/src/main/java/org/apache/myfaces/el/resolver/ImportConstantsELResolver.java
index 8db6e8f..5fddb9c 100644
--- a/impl/src/main/java/org/apache/myfaces/el/resolver/ImportConstantsELResolver.java
+++ b/impl/src/main/java/org/apache/myfaces/el/resolver/ImportConstantsELResolver.java
@@ -120,13 +120,8 @@ public final class ImportConstantsELResolver extends ELResolver
             String type = importConstantsMap.get((String)property);
             if (type != null)
             {
-                Map<String, Object> constantsMap = constantsTypeMap.get(type);
-                if (constantsMap == null)
-                {
-                    constantsMap = collectConstants(type);
-                    constantsTypeMap.put(type, constantsMap);
-                }
-                if (constantsMap != null && !constantsMap.isEmpty())
+                Map<String, Object> constantsMap = constantsTypeMap.computeIfAbsent(type,
k -> collectConstants(type));
+                if (!constantsMap.isEmpty())
                 {
                     context.setPropertyResolved(true);
                     return constantsMap;
diff --git a/impl/src/main/java/org/apache/myfaces/flow/FlowHandlerImpl.java b/impl/src/main/java/org/apache/myfaces/flow/FlowHandlerImpl.java
index a2148f6..94f9708 100644
--- a/impl/src/main/java/org/apache/myfaces/flow/FlowHandlerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/flow/FlowHandlerImpl.java
@@ -118,12 +118,8 @@ public class FlowHandlerImpl extends FlowHandler implements SystemEventListener
             throw new IllegalArgumentException("Flow must have a non null definingDocumentId");
         }
         
-        Map<String, Flow> flowMap = _flowMapByDocumentId.get(definingDocumentId);
-        if (flowMap == null)
-        {
-            flowMap = new ConcurrentHashMap<String, Flow>();
-            _flowMapByDocumentId.put(definingDocumentId, flowMap);
-        }
+        Map<String, Flow> flowMap = _flowMapByDocumentId.computeIfAbsent(definingDocumentId,
+                k -> new ConcurrentHashMap<>());
         flowMap.put(id, toAdd);
         
         Flow duplicateFlow = _flowMapById.get(id);
@@ -816,12 +812,8 @@ public class FlowHandlerImpl extends FlowHandler implements SystemEventListener
     {
         Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
         String currentFlowMapKey = CURRENT_FLOW_STACK + clientWindow.getId();
-        List<_FlowContextualInfo> currentFlowStack = (List<_FlowContextualInfo>)
sessionMap.get(currentFlowMapKey);
-        if (currentFlowStack == null)
-        {
-            currentFlowStack = new ArrayList<_FlowContextualInfo>(4);
-            sessionMap.put(currentFlowMapKey, currentFlowStack);
-        }
+        List<_FlowContextualInfo> currentFlowStack = (List<_FlowContextualInfo>)
+                sessionMap.computeIfAbsent(currentFlowMapKey, k -> new ArrayList<>(4));
         if (!currentFlowStack.isEmpty())
         {
             currentFlowStack.get(currentFlowStack.size()-1).setLastDisplayedViewId(context.getViewRoot().getViewId());
@@ -1001,12 +993,8 @@ public class FlowHandlerImpl extends FlowHandler implements SystemEventListener
     {
         Map<Object, Object> attributesMap = context.getAttributes();
         String currentFlowMapKey = stackKey + clientWindow.getId();
-        List<_FlowContextualInfo> currentFlowStack = (List<_FlowContextualInfo>)
attributesMap.get(currentFlowMapKey);
-        if (currentFlowStack == null)
-        {
-            currentFlowStack = new ArrayList<_FlowContextualInfo>(4);
-            attributesMap.put(currentFlowMapKey, currentFlowStack);
-        }
+        List<_FlowContextualInfo> currentFlowStack = (List<_FlowContextualInfo>)
+                attributesMap.computeIfAbsent(currentFlowMapKey, k -> new ArrayList<_FlowContextualInfo>(4));
         currentFlowStack.add(flowReference);
     }
 
diff --git a/impl/src/main/java/org/apache/myfaces/flow/FlowImpl.java b/impl/src/main/java/org/apache/myfaces/flow/FlowImpl.java
index 942635a..3425ffe 100644
--- a/impl/src/main/java/org/apache/myfaces/flow/FlowImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/flow/FlowImpl.java
@@ -338,24 +338,18 @@ public class FlowImpl extends Flow implements Freezable
     public void addNavigationCases(String fromViewId, Set<NavigationCase> navigationCases)
     {
         checkInitialized();
-        Set<NavigationCase> navigationCaseSet = _navigationCases.get(fromViewId);
-        if (navigationCaseSet == null)
-        {
-            navigationCaseSet = new HashSet<NavigationCase>();
-            _navigationCases.put(fromViewId, navigationCaseSet);
-        }
+
+        Set<NavigationCase> navigationCaseSet = _navigationCases.computeIfAbsent(fromViewId,
+                k -> new HashSet<NavigationCase>());
         navigationCaseSet.addAll(navigationCases);
     }
     
     public void addNavigationCase(NavigationCase navigationCase)
     {
         checkInitialized();
-        Set<NavigationCase> navigationCaseSet = _navigationCases.get(navigationCase.getFromViewId());
-        if (navigationCaseSet == null)
-        {
-            navigationCaseSet = new HashSet<NavigationCase>();
-            _navigationCases.put(navigationCase.getFromViewId(), navigationCaseSet);
-        }
+
+        Set<NavigationCase> navigationCaseSet = _navigationCases.computeIfAbsent(navigationCase.getFromViewId(),
+                k -> new HashSet<NavigationCase>());
         navigationCaseSet.add(navigationCase);
     }
     
diff --git a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
index 9840627..32ee3d4 100644
--- a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
@@ -137,18 +137,14 @@ public class FlowScopeBeanHolder implements Serializable
         Map<Object, Object> map = null;
         if (create)
         {
-            ContextualStorage contextualStorage = getContextualStorage(
-                beanManager, flowClientWindowId);
-            ContextualInstanceInfo info = contextualStorage.getStorage().get(CURRENT_FLOW_SCOPE_MAP);
-            if (info == null)
-            {
-                info = new ContextualInstanceInfo<Object>();
-                contextualStorage.getStorage().put(CURRENT_FLOW_SCOPE_MAP, info);
-            }
+            ContextualStorage contextualStorage = getContextualStorage(beanManager, flowClientWindowId);
+            ContextualInstanceInfo info = contextualStorage.getStorage().computeIfAbsent(CURRENT_FLOW_SCOPE_MAP,
+                    k -> new ContextualInstanceInfo<>());
+
             map = (Map<Object, Object>) info.getContextualInstance();
             if (map == null)
             {
-                map = new HashMap<Object,Object>();
+                map = new HashMap<>();
                 info.setContextualInstance(map);
             }
         }
diff --git a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java
index 22aea28..d354d3f 100644
--- a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java
@@ -74,16 +74,8 @@ public class FlowScopedContextImpl implements Context
     
     protected FlowScopeBeanHolder getFlowScopeBeanHolder(FacesContext facesContext)
     {
-        FlowScopeBeanHolder flowScopeBeanHolder = (FlowScopeBeanHolder) 
-            facesContext.getExternalContext().getApplicationMap().get(
-                "oam.flow.FlowScopeBeanHolder");
-        if (flowScopeBeanHolder == null)
-        {
-            flowScopeBeanHolder = CDIUtils.get(beanManager, FlowScopeBeanHolder.class);
-            facesContext.getExternalContext().getApplicationMap().put(
-                "oam.flow.FlowScopeBeanHolder", flowScopeBeanHolder);
-        }
-        return flowScopeBeanHolder;
+        return (FlowScopeBeanHolder) facesContext.getExternalContext().getApplicationMap().computeIfAbsent(
+                "oam.flow.FlowScopeBeanHolder", k -> CDIUtils.get(beanManager, FlowScopeBeanHolder.class));
     }
     
     public String getCurrentClientWindowFlowId(FacesContext facesContext)
@@ -139,9 +131,8 @@ public class FlowScopedContextImpl implements Context
         {
             return false;
         }
-        Flow flow = facesContext.getApplication().
-            getFlowHandler().getCurrentFlow(facesContext);
         
+        Flow flow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
         return flow != null;
     }
 
@@ -160,7 +151,7 @@ public class FlowScopedContextImpl implements Context
 
         checkActive(facesContext);
 
-        FlowReference reference = flowBeanReferences.get(((Bean)bean).getBeanClass());
+        FlowReference reference = flowBeanReferences.get(((Bean) bean).getBeanClass());
         if (reference != null)
         {
             String flowMapKey = FlowUtils.getFlowMapKey(facesContext, reference);
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/FaceletState.java
b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/FaceletState.java
index cf52b7e..1ef77ed 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/FaceletState.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/FaceletState.java
@@ -137,14 +137,10 @@ public class FaceletState implements StateHolder, Serializable
     {
         if (bindingsMap == null)
         {
-            bindingsMap = new HashMap<String, Map<String, ValueExpression>>();
-        }
-        Map<String, ValueExpression> bindings = bindingsMap.get(uniqueId);
-        if (bindings == null)
-        {
-            bindings = new HashMap<String, ValueExpression>();
-            bindingsMap.put(uniqueId, bindings);
+            bindingsMap = new HashMap<>();
         }
+
+        Map<String, ValueExpression> bindings = bindingsMap.computeIfAbsent(uniqueId,
k -> new HashMap<>());
         bindings.put(key, expr);
     }
     
@@ -169,6 +165,7 @@ public class FaceletState implements StateHolder, Serializable
         {
             return null;
         }
+
         Map<String, ValueExpression> bindings = bindingsMap.get(uniqueId);
         if (bindings == null)
         {


Mime
View raw message