There is default value for "type" set to "String" so in this case it should not return null. I don't think it's necessary but it would be really small change. Should I add something like this?

    -      if (project != null)
    +      if (fieldType != null && project != null)