Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 27697 invoked from network); 17 Feb 2009 00:10:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Feb 2009 00:10:22 -0000 Received: (qmail 53497 invoked by uid 500); 17 Feb 2009 00:10:20 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 53441 invoked by uid 500); 17 Feb 2009 00:10:20 -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 53430 invoked by uid 99); 17 Feb 2009 00:10:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Feb 2009 16:10:20 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Feb 2009 00:10:20 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7E120234C48C for ; Mon, 16 Feb 2009 16:09:59 -0800 (PST) Message-ID: <1696390813.1234829399515.JavaMail.jira@brutus> Date: Mon, 16 Feb 2009 16:09:59 -0800 (PST) From: "Sebb (JIRA)" To: issues@commons.apache.org Subject: [jira] Created: (BEANUTILS-336) MappedPropertyDescriptor#reLoadClass() possible NPE / odd code; also swallows Throwable MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org MappedPropertyDescriptor#reLoadClass() possible NPE / odd code; also swallows Throwable --------------------------------------------------------------------------------------- Key: BEANUTILS-336 URL: https://issues.apache.org/jira/browse/BEANUTILS-336 Project: Commons BeanUtils Issue Type: Bug Components: Bean / Property Utils Reporter: Sebb MappedPropertyDescriptor#reLoadClass() possible NPE / odd code {code} private Class reLoadClass() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); // Try the context class loader if (classLoader != null) { try { return classLoader.loadClass(className); } catch (Throwable t) { // ignore } } // Try this class's class loader try { return classLoader.loadClass(className); } catch (Throwable t) { return null; } } {code} The second call to classLoader.loadClass(className) is likely to fail with NPE - if it is ever called. The comments suggest that the second loadClass() invocation should be done using a different class loader, however this is not done. Does the code really want to try loading the class twice using the same classloader? This is what will happen if the initial loadClass() fails. Another problem with the code is that it swallows Throwable. It would be better to catch just the expected Exceptions - or even Exception, but not Throwable. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.