1. Java Rosa
  2. javarosa
  3. Issues
Issue #66 new

FormDef::deleteRepeat causes NullPointerException -- erroneous multiplicity adjustments

Mitch Sundt
created an issue

This exists in javarosa and javarosa-pending.

https://bitbucket.org/javarosa/javarosa/src/8acbd7900f03/core/src/org/javarosa/core/model/FormDef.java

lines 293-299: // update multiplicities of other child nodes for (int i = 0; i < parentElement.getNumChildren(); i++) { TreeElement child = parentElement.getChildAt(i); if (child.getMult() > childMult) { child.setMult(child.getMult() - 1); } }

There should be an additional guard condition on the if:

        if (child.getName().equals(deleteElement.getName()) 
                        && child.getMult() > childMult) {
            child.setMult(child.getMult() - 1);
        }

Attached is an example form. If you add 2 owners, then add 2 pets, and then delete the pets, the symptom is that the multiplicities for the 2 owners gets messed up (Force Close in ODK Collect 1.2).

Basically, the deletion of the pets causes an adjustment to the multiplicities of the owners, leading to the 2 owners both having '0' multiplicity.

Comments (0)

  1. Log in to comment