You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Stefan Fromm (JIRA)" <ji...@codehaus.org> on 2013/06/18 12:03:03 UTC
[jira] (MNG-5485) ClassRealmAdapter.getParent() handles null
parents incorrectly
Stefan Fromm created MNG-5485:
---------------------------------
Summary: 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