aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hugh...@apache.org
Subject svn commit: r1624513 - /aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java
Date Fri, 12 Sep 2014 12:15:40 GMT
Author: hughesj
Date: Fri Sep 12 12:15:39 2014
New Revision: 1624513

URL: http://svn.apache.org/r1624513
Log:
ARIES-1242: Unguarded logging calls containing expensive toString() caused low performance

Modified:
    aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java

Modified: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java?rev=1624513&r1=1624512&r2=1624513&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java
(original)
+++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java
Fri Sep 12 12:15:39 2014
@@ -84,7 +84,7 @@ public class ObjectFactoryHelper impleme
             obj = ((Referenceable) obj).getReference();
         }
         
-        logger.log(Level.FINE, "obj = " + obj);
+        if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "obj = " + obj);
 
         Object result = obj;
 
@@ -102,14 +102,14 @@ public class ObjectFactoryHelper impleme
             }
         }
         
-		logger.log(Level.FINE, "Step 4: result = " + result);
+		if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Step 4: result = " + result);
 
         // Step 5 - if we still don't have a resolved object goto the object factory builds
in the SR.
         if (result == null || result == obj) {
             result = getObjectInstanceUsingObjectFactoryBuilders(obj, name, nameCtx, environment);
         }
 
-		logger.log(Level.FINE, "Step 5: result = " + result);
+		if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Step 5: result = " + result);
 
         // Step 6 - Attempt to use all the registered ObjectFactories in the SR.
         if (result == null || result == obj) {                
@@ -119,7 +119,7 @@ public class ObjectFactoryHelper impleme
             }
         }
  
-		logger.log(Level.FINE, "Step 6: result = " + result);
+		if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Step 6: result = " + result);
 
 		// Extra, non-standard, bonus step 7. If javax.naming.OBJECT_FACTORIES is set as 
 		// a property in the environment, use its value to construct additional object factories.

@@ -129,7 +129,7 @@ public class ObjectFactoryHelper impleme
 			result = getObjectInstanceViaContextDotObjectFactories(obj, name, nameCtx, environment);
 		} 
 		
-		logger.log(Level.FINE, "Step 7: result = " + result);
+		if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Step 7: result = " + result);
 
         return (result == null) ? obj : result;
     }
@@ -170,27 +170,27 @@ public class ObjectFactoryHelper impleme
 					Class<ObjectFactory> clz = (Class<ObjectFactory>) cl.loadClass(cand);
 					factory = clz.newInstance();
 				} catch (Exception e) {
-					logger.log(Level.FINE, "Exception instantiating factory: " + e);
+					if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Exception instantiating factory:
" + e);
 					continue;
 				}
-				logger.log(Level.FINE, "cand=" + cand + " factory=" + factory);
+				if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "cand=" + cand + " factory="
+ factory);
 				if (factory != null) {
 					if(factory instanceof DirObjectFactory)
 					{
-						logger.log(Level.FINE, "its a DirObjectFactory");
+						if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "its a DirObjectFactory");
 						final DirObjectFactory dirFactory = (DirObjectFactory) factory;
 						result = dirFactory.getObjectInstance(obj, name, nameCtx, environment, attrs);
 					}
 					else
 					{
-						logger.log(Level.FINE, "its an ObjectFactory");
+						if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "its an ObjectFactory");
 						result = factory.getObjectInstance(obj, name, nameCtx, environment);
 					}
 				}
 				if (result != null && result != obj) break;
 			}
 		}
-		logger.log(Level.FINE, "result = " + result);
+		if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "result = " + result);
 		return (result == null) ? obj : result;
     }
 



Mime
View raw message