commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (BEANUTILS-336) MappedPropertyDescriptor#reLoadClass() possible NPE / odd code; also swallows Throwable
Date Tue, 04 Aug 2009 00:40:14 GMT

     [ https://issues.apache.org/jira/browse/BEANUTILS-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Niall Pemberton resolved BEANUTILS-336.
---------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.8.1
         Assignee: Niall Pemberton

Thanks Sebb - fixed the NPE and now only swallowing ClassNotFoundException

http://svn.apache.org/viewvc?view=rev&revision=800643

> 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
>            Assignee: Niall Pemberton
>             Fix For: 1.8.1
>
>
> 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.


Mime
View raw message