Java Null Dereference when setting a field to null - Fortify
问题 Fortify is complaining about a Null Dereference when I set a field to null: String sortName = null; if (lastName != null && lastName.length() > 0) { sortName = lastName; } sortOptions.setSortField(sortName); <-- Fortify Null Dereference Fortify's analysis trace says: Assigned null: sortName Branch taken: if (lastName != null && lastName.length() > 0) Dereferenced: sortName I could try: if (sortName == null) sortOptions.setSortField(null); else sortOptions.setSortField(sortName); But that