[OSM-dev] Osmosis error read-xml (NullPointerException)

Brett Henderson brett at bretth.com
Sun May 31 23:06:27 BST 2009

marcus.wolschon at googlemail.com wrote:
> On Thu, 28 May 2009 17:42:02 +1000, Brett Henderson <brett at bretth.com>
> wrote:
>> Line 43 of RelationMemberWriter above deals with the relation member 
>> role.  Your osm file above is missing all of the role attributes on 
>> relation members which would cause this problem to occur.
>> Perhaps xapi doesn't include the role attribute if it is empty ... I 
>> thought it was mandatory ...
> So maybe we should add a
> if (member.getRole() == null) {
>    throw new IllegalArgumentException("no role for reltion-member "
>    + member.getElementID() + " of relation " + relation.getID());
> }
> to give better error-messages in this case.
> or much better, add this to 
> RelationMenber:setRole(final String aRole)
> so no illegal members can ever be created.
> (and of cause call the setters from the constructor
>  as is good practice to make subclassing easier.)
Yep, I'd prefer to add it here so that it's not possible to create an 
invalid member.  I haven't done null checks anywhere so far due to the 
amount of extra code it requires, but it sounds like it would be a good 
idea, at least on the data classes.


More information about the dev mailing list