commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 38626] New: - LogFactory#getLogFactory should not look for method every time
Date Sun, 12 Feb 2006 22:24:01 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38626>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38626

           Summary: LogFactory#getLogFactory should not look for method
                    every time
           Product: Commons
           Version: 1.0.4
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Logging
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: matthias.ernst@coremedia.com


LogFactory checks for the existence of Thread#getContextClassLoader every time
#getLogFactory is invoked and does a reflective invocation. This is
unnecessarily expensive if many Log objects are created. An easy patch is to
remember the Method object; the lookup happens only once and it will massively
profit from reflection optimizations after a number of calls (a Java code stub
is generated by the reflection package).

Patch:

419a420,426
>     private static Method GET_CONTEXT_CLASS_LOADER = null;
>     static {
>       try {
>         GET_CONTEXT_CLASS_LOADER = Thread.class.getMethod("getContextClassLoad
er", null);
>       } catch (NoSuchMethodException e) {
>       }
>     }
436,439c443
<         try {
<             // Are we running on a JDK 1.2 or later system?
<             Method method = Thread.class.getMethod("getContextClassLoader", nu
ll);
<
---
>         if(GET_CONTEXT_CLASS_LOADER != null) {
442c446
<                 classLoader = (ClassLoader)method.invoke(Thread.currentThread(
), null);
---
>                 classLoader = (ClassLoader)GET_CONTEXT_CLASS_LOADER.invoke(Thr
ead.currentThread(), null);
472c476
<         } catch (NoSuchMethodException e) {
---
>         } else {

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message