Buggy code:
@ Entity @ Table ( name = "User" ) public class User extends AuditableEntity { private static final long serialVersionUID = - 5821877436246475858L ; public static final int NAME_LENGTH = 40 ; public static final int PASSWORD_LENGTH = 256 ; private String name ; private String displayName ; private String password ; private String salt ; private boolean approved = true ; private boolean locked = false ; private Boolean isLdapUser = false ; private boolean wasLdapUser = false ; private Boolean hasGlobalGroupAccess = false ; private Boolean hasChangedInitialPassword = false ; private Date lastLoginDate = new Date ( ) ; private Date lastPasswordChangedDate = new Date ( ) ; private int failedPasswordAttempts = 0 ; private Date failedPasswordAttemptWindowStart = new Date ( ) ; private String unencryptedPassword ; private String passwordConfirm ; private String currentPassword ; private Role globalRole ; private List < AccessControlTeamMap > accessControlTeamMaps ; @ Column ( length = User . NAME_LENGTH , nullable = false ) @ JsonView ( { TableRow . class , FormInfo . class } ) public String getName ( ) { } public void setName ( String name ) { } @ Column ( length = User . PASSWORD_LENGTH , nullable = false ) @ JsonIgnore public String getPassword ( ) { } public void setPassword ( String password ) { } @ Column ( length = User . PASSWORD_LENGTH , nullable = false ) @ JsonIgnore public String getSalt ( ) { } public void setSalt ( String salt ) { } @ Column ( nullable = false ) @ JsonIgnore public boolean isApproved ( ) { } public void setApproved ( boolean approved ) { } @ Column ( nullable = false ) @ JsonIgnore public boolean isLocked ( ) { } public void setLocked ( boolean locked ) { } @ Temporal ( TemporalType . TIMESTAMP ) @ Column ( nullable = false ) @ JsonIgnore public Date getLastPasswordChangedDate ( ) { } public void setLastPasswordChangedDate ( Date lastPasswordChangedDate ) { } @ Temporal ( TemporalType . TIMESTAMP ) @ Column ( nullable = false ) @ JsonIgnore public Date getLastLoginDate ( ) { } public void setLastLoginDate ( Date lastLoginDate ) { } @ Column ( nullable = false ) @ JsonIgnore public int getFailedPasswordAttempts ( ) { } public void setFailedPasswordAttempts ( int failedPasswordAttempts ) { } @ Temporal ( TemporalType . TIMESTAMP ) @ Column ( nullable = false ) @ JsonIgnore public Date getFailedPasswordAttemptWindowStart ( ) { } public void setFailedPasswordAttemptWindowStart ( Date failedPasswordAttemptWindowStart ) { } @ Transient @ JsonIgnore public String getUnencryptedPassword ( ) { } public void setUnencryptedPassword ( String unencryptedPassword ) { } @ Transient @ JsonIgnore public String getPasswordConfirm ( ) { } public void setPasswordConfirm ( String passwordConfirm ) { } @ Transient @ JsonIgnore public String getCurrentPassword ( ) { } public void setCurrentPassword ( String currentPassword ) { } @ Column @ JsonIgnore public Boolean isHasChangedInitialPassword ( ) { } public void setHasChangedInitialPassword ( Boolean hasChangedInitialPassword ) { } @ Column @ JsonView ( TableRow . class ) public Boolean getHasGlobalGroupAccess ( ) { } public void setHasGlobalGroupAccess ( Boolean hasGlobalGroupAccess ) { } @ ManyToOne @ JoinColumn ( name = "roleId" , nullable = true ) @ JsonView ( TableRow . class ) public Role getGlobalRole ( ) { } public void setGlobalRole ( Role globalRole ) { } @ OneToMany ( mappedBy = "user" ) @ JsonIgnore public List < AccessControlTeamMap > getAccessControlTeamMaps ( ) { } public void setAccessControlTeamMaps ( List < AccessControlTeamMap > accessControlTeamMaps ) { } @ Column ( nullable = true ) @ JsonView ( TableRow . class ) public Boolean getIsLdapUser ( ) { } public void setIsLdapUser ( Boolean isLdapUser ) { } @ Column ( length = User . PASSWORD_LENGTH , nullable = true ) @ JsonView ( TableRow . class ) public String getDisplayName ( ) { } public void setDisplayName ( String displayName ) { } @ Transient @ JsonView ( TableRow . class ) public boolean getIsDeletable ( ) { } public void setIsDeletable ( boolean deletable ) { } @ Transient public boolean getIsThisUser ( ) { } public void setIsThisUser ( boolean isThisUser ) { } @ Transient public boolean getWasLdap ( ) { } public void setWasLdapUser ( boolean wasLdapUser ) { } private boolean deletable ; private boolean isThisUser ; @ Transient @ JsonProperty ( "bestName" ) public String getBestName ( ) { <START_BUG> return ( displayName ) == null ? name : displayName ; <END_BUG> } }

Fix:
return ( ( displayName ) == null ) || ( displayName . isEmpty ( ) ) ? name : displayName ;