Are "if" clauses without braces allowed? I haven't seen those in a while.
Glen On 10/12/2011 03:38 PM, [email protected] wrote:
Author: jbonofre Date: Wed Oct 12 19:38:14 2011 New Revision: 1182554 URL: http://svn.apache.org/viewvc?rev=1182554&view=rev Log: [KARAF-932] Initialize the config properties if null to avoid NPE Modified: karaf/branches/karaf-2.2.x/management/mbeans/config/src/main/java/org/apache/karaf/management/mbeans/config/internal/ConfigMBeanImpl.java Modified: karaf/branches/karaf-2.2.x/management/mbeans/config/src/main/java/org/apache/karaf/management/mbeans/config/internal/ConfigMBeanImpl.java URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/management/mbeans/config/src/main/java/org/apache/karaf/management/mbeans/config/internal/ConfigMBeanImpl.java?rev=1182554&r1=1182553&r2=1182554&view=diff ============================================================================== --- karaf/branches/karaf-2.2.x/management/mbeans/config/src/main/java/org/apache/karaf/management/mbeans/config/internal/ConfigMBeanImpl.java (original) +++ karaf/branches/karaf-2.2.x/management/mbeans/config/src/main/java/org/apache/karaf/management/mbeans/config/internal/ConfigMBeanImpl.java Wed Oct 12 19:38:14 2011 @@ -85,6 +85,8 @@ public class ConfigMBeanImpl extends Sta throw new IllegalArgumentException("Configuration PID " + pid + " doesn't exist"); } Dictionary dictionary = configuration.getProperties(); + if (dictionary == null) + dictionary = new java.util.Properties(); Map<String, String> propertiesMap = new HashMap<String, String>(); for (Enumeration e = dictionary.keys(); e.hasMoreElements(); ) { Object key = e.nextElement(); @@ -100,6 +102,8 @@ public class ConfigMBeanImpl extends Sta throw new IllegalArgumentException("Configuration PID " + pid + " doesn't exist"); } Dictionary dictionary = configuration.getProperties(); + if (dictionary == null) + dictionary = new java.util.Properties(); dictionary.remove(key); store(pid, dictionary, false); } @@ -110,6 +114,8 @@ public class ConfigMBeanImpl extends Sta throw new IllegalArgumentException("Configuration PID " + pid + " doesn't exist"); } Dictionary dictionary = configuration.getProperties(); + if (dictionary == null) + dictionary = new java.util.Properties(); Object currentValue = dictionary.get(key); if (currentValue == null) { dictionary.put(key, value); @@ -127,6 +133,8 @@ public class ConfigMBeanImpl extends Sta throw new IllegalArgumentException("Configuration PID " + pid + " doesn't exist"); } Dictionary dictionary = configuration.getProperties(); + if (dictionary == null) + dictionary = new java.util.Properties(); dictionary.put(key, value); store(pid, dictionary, false); }
-- Glen Mazza Talend - http://www.talend.com/apache Blog - http://www.jroller.com/gmazza Twitter - glenmazza
