Menu

#11 Nullcheck in JOXBeanOutput.formatValue before line: 590

open
nobody
None
5
2010-08-16
2010-08-16
No

There should be a check if value is null before calling value.getClass(). Otherwise there will be a NullpointerException and the checks in the return-statements are useless.

The easiest way fixing this problem would be changing the statment:
Class type = value.getClass();
to:
Class type = (value !=null) ? value.getClass() : String.class;

due to this change, all other nullchecks could be removed, except the nullcheck for String-values on line 607.

Discussion

  • Clemens Gatterer

    the file with the proposed correcture

     
  • Clemens Gatterer

    The Nullpointer occurs if an Array contains null.

     

Log in to post a comment.

MongoDB Logo MongoDB