[ 
https://jira.codehaus.org/browse/MNG-5485?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=339903#comment-339903
 ] 

Jason van Zyl commented on MNG-5485:
------------------------------------

This code is now all deprecated in ClassWorlds and will be removed in the next 
major release.
                
> ClassRealmAdapter.getParent() handles null parents incorrectly
> --------------------------------------------------------------
>
>                 Key: MNG-5485
>                 URL: https://jira.codehaus.org/browse/MNG-5485
>             Project: Maven 2 & 3
>          Issue Type: Bug
>    Affects Versions: 3.0.5
>         Environment: Java 1.6.0_30, Windows XP Professional 2002 SP3
>            Reporter: Stefan Fromm
>
> Here is the code from plexus classworlds 2.4.x.
> {noformat}
> public ClassRealm getParent()
> {
>   return ClassRealmAdapter.getInstance( realm.getParentRealm() );
> }
> public ClassRealm getParentRealm()
> {
>   return ClassRealmAdapter.getInstance( realm.getParentRealm() );
> }
> public static ClassRealmAdapter getInstance( 
> org.codehaus.plexus.classworlds.realm.ClassRealm newRealm )
> {
>   ClassRealmAdapter adapter = new ClassRealmAdapter( newRealm );
>   return adapter;
> }
> {noformat}
> If the parent of the backend realm is {{null}}, then there is returned a new 
> {{ClassRealmAdapter}} instead of {{null}}. Calling methods on the returned 
> {{ClassRealmAdapter}} produces NPEs.
> I think, that {{getParent()}} and {{getParentRealm()}} could be patched like 
> this:
> {noformat}
> public ClassRealm getParentRealm()
> {
>   return realm.getParentRealm() != null 
>     ? ClassRealmAdapter.getInstance( realm.getParentRealm())
>     : null;
> }
> public ClassRealm getParent()
> {
>   return getParentRealm();
> }
> {noformat}
> Or should {{null}} be handled in {{ClassRealmAdapter.getInstance()}}?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to