don't override existing fields with a null value

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163717 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-03-30 08:15:36 +00:00
parent 0ee892dfdc
commit 92600f4e55
1 changed files with 22 additions and 19 deletions

View File

@ -544,30 +544,33 @@ public class DefaultPluginManager
String key = (String) i.next();
Object value = map.get( key );
Class clazz = plugin.getClass();
try
if ( value != null )
{
Field f = findPluginField( clazz, key );
boolean accessible = f.isAccessible();
if ( !accessible )
Class clazz = plugin.getClass();
try
{
f.setAccessible( true );
Field f = findPluginField( clazz, key );
boolean accessible = f.isAccessible();
if ( !accessible )
{
f.setAccessible( true );
}
f.set( plugin, value );
if ( !accessible )
{
f.setAccessible( false );
}
}
f.set( plugin, value );
if ( !accessible )
catch ( NoSuchFieldException e )
{
f.setAccessible( false );
throw new PluginConfigurationException( "Unable to set field '" + key + "' on '" + clazz + "'" );
}
catch ( IllegalAccessException e )
{
throw new PluginConfigurationException( "Unable to set field '" + key + "' on '" + clazz + "'" );
}
}
catch ( NoSuchFieldException e )
{
throw new PluginConfigurationException( "Unable to set field '" + key + "' on '" + clazz + "'" );
}
catch ( IllegalAccessException e )
{
throw new PluginConfigurationException( "Unable to set field '" + key + "' on '" + clazz + "'" );
}
}
}