Menu

#1355 NullPointerException in getNaturalExactMass()

master
closed
nobody
None
1
2014-12-28
2014-12-28
No

I noticed that the BODRIsotope class returns null from its getBuilder() method:

@Override
@TestMethod("untested")
public IChemObjectBuilder getBuilder() {
    return null;
}

This causes a NullPointerException in MolecularFormulaManipulator.getNaturalExactMass() if the formula contains such isotopes.

Sample code (throws NullPointerException at the last line):

        Isotopes is = Isotopes.getInstance();
        IIsotope carbon = is.getMajorIsotope("C");
        MolecularFormula mf = new MolecularFormula();
        mf.addIsotope(carbon, 10);
        double mass = MolecularFormulaManipulator.getNaturalExactMass(mf);

Discussion

  • Egon Willighagen

    Confirmed. Submitting a patch.

     
  • Egon Willighagen

     
  • John May

    John May - 2014-12-28

    Applied and pushed

     
  • John May

    John May - 2014-12-28
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,3 @@
    -
     I noticed that the BODRIsotope class returns null from its getBuilder() method:
    
         @Override
    
    • status: open --> closed