Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 15B8011B02 for ; Fri, 27 Jun 2014 12:09:26 +0000 (UTC) Received: (qmail 3586 invoked by uid 500); 27 Jun 2014 12:09:25 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 3435 invoked by uid 500); 27 Jun 2014 12:09:25 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 3217 invoked by uid 99); 27 Jun 2014 12:09:25 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jun 2014 12:09:25 +0000 Date: Fri, 27 Jun 2014 12:09:25 +0000 (UTC) From: "Thomas Neidhart (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (LOGGING-37) [logging] LogFactory#getLogFactory should not look for method every time MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LOGGING-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thomas Neidhart resolved LOGGING-37. ------------------------------------ Resolution: Fixed Fix Version/s: 1.2 Fixed in r1606041. > [logging] LogFactory#getLogFactory should not look for method every time > ------------------------------------------------------------------------ > > Key: LOGGING-37 > URL: https://issues.apache.org/jira/browse/LOGGING-37 > Project: Commons Logging > Issue Type: Bug > Affects Versions: 1.0.4 > Environment: Operating System: other > Platform: Other > Reporter: Matthias Ernst > Fix For: 1.2 > > > 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 { -- This message was sent by Atlassian JIRA (v6.2#6252)