From 92600f4e55e47d42f33534d13d320beeea271e5d Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Wed, 30 Mar 2005 08:15:36 +0000 Subject: [PATCH] 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 --- .../maven/plugin/DefaultPluginManager.java | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index 1b206cd975..5d28119466 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -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 + "'" ); } } }