Improve readability of empty collection checks
This commit is contained in:
committed by
Josh Cummings
parent
31bdaf720d
commit
b8aa78829c
@@ -80,7 +80,7 @@ public class RunAsManagerImpl implements RunAsManager, InitializingBean {
|
||||
newAuthorities.add(extraAuthority);
|
||||
}
|
||||
}
|
||||
if (newAuthorities.size() == 0) {
|
||||
if (newAuthorities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
// Add existing authorities
|
||||
|
||||
@@ -182,7 +182,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, M
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
List<UserDetails> users = loadUsersByUsername(username);
|
||||
if (users.size() == 0) {
|
||||
if (users.isEmpty()) {
|
||||
this.logger.debug("Query returned no results for user '" + username + "'");
|
||||
throw new UsernameNotFoundException(this.messages.getMessage("JdbcDaoImpl.notFound",
|
||||
new Object[] { username }, "Username {0} not found"));
|
||||
@@ -197,7 +197,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, M
|
||||
}
|
||||
List<GrantedAuthority> dbAuths = new ArrayList<>(dbAuthsSet);
|
||||
addCustomAuthorities(user.getUsername(), dbAuths);
|
||||
if (dbAuths.size() == 0) {
|
||||
if (dbAuths.isEmpty()) {
|
||||
this.logger.debug("User '" + username + "' has no authorities and will be treated as 'not found'");
|
||||
throw new UsernameNotFoundException(this.messages.getMessage("JdbcDaoImpl.noAuthority",
|
||||
new Object[] { username }, "User {0} has no GrantedAuthority"));
|
||||
|
||||
Reference in New Issue
Block a user