Yes I agree, but you are invoking getTask method (l: 57) which in some cases can return null. Please confront with Database.java class. Good practice is to protect against it.