You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2012/01/16 19:28:24 UTC

svn commit: r1232101 - /myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java

Author: lu4242
Date: Mon Jan 16 18:28:24 2012
New Revision: 1232101

URL: http://svn.apache.org/viewvc?rev=1232101&view=rev
Log:
MYFACES-3266 [perf] [concurrency] check correct logger creation

Modified:
    myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java

Modified: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java?rev=1232101&r1=1232100&r2=1232101&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java (original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java Mon Jan 16 18:28:24 2012
@@ -79,7 +79,7 @@ public class UIViewRoot extends UICompon
     public static final String UNIQUE_ID_PREFIX = "j_id";
     public static final String VIEW_PARAMETERS_KEY = "javax.faces.component.VIEW_PARAMETERS_KEY";
 
-    private final Logger logger = Logger.getLogger(UIViewRoot.class.getName());
+    private transient Logger logger = null;
 
     private static final PhaseProcessor APPLY_REQUEST_VALUES_PROCESSOR = new ApplyRequestValuesPhaseProcessor();
     private static final PhaseProcessor PROCESS_VALIDATORS_PROCESSOR = new ProcessValidatorPhaseProcessor();
@@ -293,7 +293,7 @@ public class UIViewRoot extends UICompon
             // broadcast reach maxLoops - probably a infinitive recursion:
             boolean production = getFacesContext().isProjectStage(ProjectStage.Production);
             Level level = production ? Level.FINE : Level.WARNING;
-            if (logger.isLoggable(level))
+            if (_getLogger().isLoggable(level))
             {
                 List<String> name = new ArrayList<String>(events.getAnyPhase().size() + events.getOnPhase().size());
                 for (FacesEvent facesEvent : events.getAnyPhase())
@@ -306,7 +306,7 @@ public class UIViewRoot extends UICompon
                     String clientId = facesEvent.getComponent().getClientId(getFacesContext());
                     name.add(clientId);
                 }
-                logger.log(level,
+                _getLogger().log(level,
                         "Event broadcating for PhaseId {0} at UIViewRoot {1} reaches maximal limit, please check " +
                         "listeners for infinite recursion. Component id: {2}",
                         new Object [] {phaseId, getViewId(), name});
@@ -364,7 +364,7 @@ public class UIViewRoot extends UICompon
         catch (Exception e)
         {
             // following the spec we have to swallow the exception
-            logger.log(Level.SEVERE, "Exception while processing phase listener: " + e.getMessage(), e);
+            _getLogger().log(Level.SEVERE, "Exception while processing phase listener: " + e.getMessage(), e);
         }
 
         if (!skipPhase)
@@ -439,7 +439,7 @@ public class UIViewRoot extends UICompon
                     }
                     catch(UnsupportedOperationException e)
                     {
-                        logger.log(Level.SEVERE, "Exception while obtaining the view metadata: " + e.getMessage(), e);
+                        _getLogger().log(Level.SEVERE, "Exception while obtaining the view metadata: " + e.getMessage(), e);
                     }
                     
                     if (metadata != null)
@@ -862,7 +862,7 @@ public class UIViewRoot extends UICompon
                 catch (Throwable t) 
                 {
                     beforePhaseSuccess[0] = false; // redundant - for clarity
-                    logger.log(Level.SEVERE, "An Exception occured while processing " +
+                    _getLogger().log(Level.SEVERE, "An Exception occured while processing " +
                                              listener.getExpressionString() + 
                                              " in Phase " + phaseId, t);
                     if (beforePhase)
@@ -1372,6 +1372,15 @@ public class UIViewRoot extends UICompon
         
         return new Events(anyPhase, onPhase);
     }
+    
+    private Logger _getLogger()
+    {
+        if (logger == null)
+        {
+            logger = Logger.getLogger(UIViewRoot.class.getName());
+        }
+        return logger;
+    }
 
     private static interface PhaseProcessor
     {