Bug 696104 - NPE on update of plugin config for existing resources
Summary: NPE on update of plugin config for existing resources
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Core Server
Version: 4.0.0.Beta2
Hardware: Unspecified
OS: Unspecified
medium
high vote
Target Milestone: ---
: ---
Assignee: Heiko W. Rupp
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: rhq42
TreeView+ depends on / blocked
 
Reported: 2011-04-13 09:24 UTC by Heiko W. Rupp
Modified: 2018-11-14 13:25 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-10-21 21:24:50 UTC


Attachments (Terms of Use)

Description Heiko W. Rupp 2011-04-13 09:24:07 UTC
I was updating a plugin configuration for an existing plugin with a new additional property.

Server showed

Caused by: java.lang.NullPointerException
        at org.rhq.enterprise.server.resource.metadata.PluginConfigurationMetadataManagerBean.updateResourcePluginConfiguration(PluginConfigurationMetadataManagerBean.java:109)
        at org.rhq.enterprise.server.resource.metadata.PluginConfigurationMetadataManagerBean.updatePluginConfigurationDefinition(PluginConfigurationMetadataManagerBean.java:83)

Code is:


                Property templateProperty = templateConfiguration.get(propertyDef.getName());
                pluginConfiguration.put(templateProperty.deepCopy(false));


Issue is that templateConfiguration only has the old definitions and is lacking the new one. So templateProperty is null and the update bombs.

Comment 1 Charles Crouch 2011-10-04 22:42:34 UTC
Heiko
So you are saying we can't add a property to the plugin configuration of an 
existing resource?

I'm sure we've done this before, e.g. the support facet work added lots of new 
properties.
Can you determine what's going on here?

Comment 2 Heiko W. Rupp 2011-10-05 08:28:25 UTC
I don't recall the details. 
Looking at master shows that I've added a null-check for this case back in July (probably got annoyed while working on as7 plugin) and forgot to add this here.


                Property templateProperty = templateConfiguration.get(propertyDef.getName());
+                if (templateProperty==null) {
+                    throw new IllegalArgumentException("The property [" + propertyDef.getName()
+                           + "] marked as required in the configuration definition of [" + propertyDef.getConfigurationDefinition().getName()
+                            + "] has no attribute 'default'");
+                } else {
                    pluginConfiguration.put(templateProperty.deepCopy(false));

This prevents the NPE and gives the plugin writer a hint what he has done wrong.

Commit is ae90811cb167e8e8c20cb4677fe1e7580714db51 in master (as of July 2011)


Note You need to log in before you can comment on or make changes to this bug.