You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Dave Christianson <dc...@farecast.com> on 2007/03/15 19:51:35 UTC

NPE in custom plugin

Not sure if this is considered a user thing or a dev thing -

I am working on a custom plugin to help generate some documentation,  
so far existing examples have been helpful but I am not clear on some  
aspects of plugin configuration. Specifically, I'm getting an NPE  
when I try to provide an empty list value in the plugin configuration.

Background:

I have a list parameter defined in my plugin Mojo that is configured  
using a setter:
	
	/**
	 * Names have been changed to protect the innocent.
	 *
	 * @parameter property=listOThings
	 */
	private List<Thing> _listOThings = Arrays.asList(new Thing [] {
			Thing.DEFAULT
	});

	public void setListOThings(List<String> listOThings) {
		this. _listOThings = (null == listOThings) ? Collections.emptyList 
() : convert(listOThings);
	}

Note that this may not be the ideal way to configure the plugin and  
is very negotiable.

If I don't specify the parameter the default value is used - this  
seems to work fine.

If I do specify a parameter with a list of values the plugin works as  
well (not sure what element name is expected):

...
<plugin>
  ...
   <configuration>
     <nodeLabelKey><value>foo</value></nodeLabelKey>
    ...


If I specify an empty list:

...
<plugin>
  ...
   <configuration>
     <nodeLabelKey></nodeLabelKey>
    ...

Then I get a null pointer exception:

java.lang.NullPointerException
         at  
org.codehaus.plexus.component.configurator.converters.ComponentValueSett 
er.configure(ComponentValueSetter.java:247)
         at  
org.codehaus.plexus.component.configurator.converters.composite.ObjectWi 
thFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java: 
137)
         at  
org.codehaus.plexus.component.configurator.converters.composite.ObjectWi 
thFieldsConverter.fromConfiguration(ObjectWithFieldsConverter.java:90)
         at  
org.codehaus.plexus.component.configurator.converters.ComponentValueSett 
er.configure(ComponentValueSetter.java:247)

Is empty list illegal? Is this a plexus thing? Is there some other  
metadata I need to provide? Any pointers would be appreciated.

regards,
Dave Christianson




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org