The log may be changed during the run time. Would there be still a better
way to check the log level ? having a local boolean would eliminate the 2nd
method call.


​


On Tue, Sep 2, 2014 at 3:06 PM, Tharindu Edirisinghe <[email protected]>
wrote:

> Hi,
>
> I'm going through the identity.provider source and found a possible
> performance issue. (However this has to be verified with some tool like
> JProfiler)
>
>
>
> turing/components/identity/org.wso2.carbon.identity.provider/4.2.2/src/main/java/org/wso2/carbon/identity/provider/openid/cache/OpenIDAssociationCache.java
>
>
>     /**
>      * Add the entry to the cache.
>      *
>      * @param association
>      */
>     public void addToCache(Association association) {
>         if (log.isDebugEnabled()) {
>             log.debug("Trying to add to cache.");
>         }
>         if (association != null && association.getHandle() != null) {
>             OpenIDIdentityCacheKey cacheKey = new
> OpenIDIdentityCacheKey(0, association.getHandle());
>             OpenIDIdentityCacheEntry cacheEntry =
>                                             new
> OpenIDIdentityCacheEntry(association.getType(),
>
> association.getMacKey(),
>
> association.getExpiry());
>             associationCache.addToCache(cacheKey, cacheEntry);
>             if (log.isDebugEnabled()) {
>                 log.debug("New entry is added to cache  : " +
> association.getHandle());
>             }
>         }
>     }
>
>
> The addToCache method is frequently called when creating OpenID
> associations. Every time a new association is created, it checks two times
> whether the debug log is enabled (shown in red above) by calling
> isDebugEnabled() method. (Assuming that the method call is costly than
> reading a local boolean variable)
>
> My suggestion is since the enabling or disabling the debug log is not
> happening during the runtime of the server, we keep a boolean variable
> inside the OpenIDAssociationCache class and assign value to that in the
> constructor of the class. Then each time the addToCache method is called,
> it will check that boolean value instead of always calling the
> log.isDebugEnabled() method.
>
> Any thoughts ??
> --
>
> Thanks & Best Regards,
>
> Tharindu Edirisinghe
> Software Engineer
>
> *WSO2 Inc*
> *email   : [email protected] <[email protected]> *
> *mobile : +94 775 181586*
> *www: :http://wso2.com <http://wso2.com/> *lean . enterprise . middleware
>
>
>


-- 

Thanks & Best Regards,

Tharindu Edirisinghe
Software Engineer

*WSO2 Inc*
*email   : [email protected] <[email protected]> *
*mobile : +94 775 181586*
*www: :http://wso2.com <http://wso2.com/> *lean . enterprise . middleware
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to