Skip to content

NullPointer when a recor-element is ignored #2

Description

@SampleName01

When a record element is ignored in the configuration XML produces a NullPointer at parsing:

Example configuration:

<record-definition> <bean name="street" class="main.Street" /> <bean name="person" class="main.Person" /> <line> <record-element length="40" beanref="person.name" converter-name="char"> <conversion-option name="justify" value="left" /> </record-element> <record-element length="2" beanref="person.age" converter-name="integer"> </record-element> <record-element length="30" beanref="person.ocuppation" converter-name="char"> <conversion-option name="justify" value="left" /> </record-element> <record-element length="5" beanref="street.zipCode" converter-name="integer"> </record-element> <record-element length="3" beanref="street.number" converter-name="integer"> </record-element> <record-element length="2" ignore-field="true"/> <!-- NullPointer --> <record-element length="50" beanref="street.address" converter-name="char" /> </line> </record-definition>

In the class LineBO (line 220), when you run the code:
if (recordElement.getCardinality().getBeanRef() != null) {

you get a null pointer exception because there is no cardinality (the record-element is ignored).
There should be a check to know if the record must be parsed (recordElement.isIgnoreField())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions