Skip to content

fix null pointer exception when ancestry is empty

Sherman Yang requested to merge fix_null_pointer into master

This MR fixes a subtle null pointer exception which could occur in the follow line: !record.getAncestry().getParents().isEmpty()) when the ancestry has no parent. The getParents() would return null. The next call isEmpty() would cause a null pointer exception when called on the returned null parents object.

The fix is to replace the line with the following line: !Collections.isEmpty(record.getAncestry().getParents())) Now if the getParents() method returns null, the Collections.isEmpty(null) call will correctly return true instead of null pointer exception as expected.

Corresponding unit tests have been updated accordingly.

Edited by Sherman Yang

Merge request reports

Loading