diff --git a/acl/src/main/java/org/springframework/security/acls/domain/AclImpl.java b/acl/src/main/java/org/springframework/security/acls/domain/AclImpl.java index 5f7a0532a36..8550450e8f2 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/AclImpl.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/AclImpl.java @@ -202,7 +202,7 @@ public boolean isGranted(List permission, List sids, boolean ad public boolean isSidLoaded(List sids) { // If loadedSides is null, this indicates all SIDs were loaded // Also return true if the caller didn't specify a SID to find - if ((this.loadedSids == null) || (sids == null) || (sids.size() == 0)) { + if ((this.loadedSids == null) || (sids == null) || sids.isEmpty()) { return true; } diff --git a/acl/src/main/java/org/springframework/security/acls/domain/DefaultPermissionFactory.java b/acl/src/main/java/org/springframework/security/acls/domain/DefaultPermissionFactory.java index 8a68843d89f..81cbe8a5735 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/DefaultPermissionFactory.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/DefaultPermissionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -140,7 +140,7 @@ public Permission buildFromName(String name) { @Override public List buildFromNames(List names) { - if ((names == null) || (names.size() == 0)) { + if ((names == null) || names.isEmpty()) { return Collections.emptyList(); } List permissions = new ArrayList<>(names.size()); diff --git a/config/src/main/java/org/springframework/security/config/http/UserDetailsServiceFactoryBean.java b/config/src/main/java/org/springframework/security/config/http/UserDetailsServiceFactoryBean.java index 227adbc0eca..00e349dc52c 100644 --- a/config/src/main/java/org/springframework/security/config/http/UserDetailsServiceFactoryBean.java +++ b/config/src/main/java/org/springframework/security/config/http/UserDetailsServiceFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,10 +101,10 @@ else if (bean instanceof UserDetailsService) { */ private UserDetailsService getUserDetailsService() { Map beans = getBeansOfType(CachingUserDetailsService.class); - if (beans.size() == 0) { + if (beans.isEmpty()) { beans = getBeansOfType(UserDetailsService.class); } - if (beans.size() == 0) { + if (beans.isEmpty()) { throw new ApplicationContextException("No UserDetailsService registered."); } if (beans.size() > 1) { @@ -124,7 +124,7 @@ public void setApplicationContext(ApplicationContext beanFactory) throws BeansEx // Check ancestor bean factories if they exist and the current one has none of the // required type BeanFactory parent = this.beanFactory.getParentBeanFactory(); - while (parent != null && beans.size() == 0) { + while (parent != null && beans.isEmpty()) { if (parent instanceof ListableBeanFactory) { beans = ((ListableBeanFactory) parent).getBeansOfType(type); } diff --git a/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java b/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java index f16bd5b13bb..e02a4340fa7 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java +++ b/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java @@ -80,7 +80,7 @@ public Authentication buildRunAs(Authentication authentication, Object object, newAuthorities.add(extraAuthority); } } - if (newAuthorities.size() == 0) { + if (newAuthorities.isEmpty()) { return null; } // Add existing authorities diff --git a/core/src/main/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImpl.java b/core/src/main/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImpl.java index 47dcf9b4a91..9772cf8a624 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImpl.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImpl.java @@ -182,7 +182,7 @@ protected void initDao() throws ApplicationContextException { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { List 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 UserDetails loadUserByUsername(String username) throws UsernameNotFoundEx } List 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")); diff --git a/ldap/src/test/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java b/ldap/src/test/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java index f322c879988..c2d02fc9f2f 100644 --- a/ldap/src/test/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java +++ b/ldap/src/test/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ public ArrayMarshaller(Comparator comparator) { * @param tree the tree to be marshalled */ public byte[] serialize(ArrayTree tree) { - if ((tree == null) || (tree.size() == 0)) { + if ((tree == null) || tree.isEmpty()) { return EMPTY_TREE; } diff --git a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AbstractAuthorizeTag.java b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AbstractAuthorizeTag.java index ff688940352..8ef39447e24 100644 --- a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AbstractAuthorizeTag.java +++ b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AbstractAuthorizeTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -207,7 +207,7 @@ private WebInvocationPrivilegeEvaluator getPrivilegeEvaluator() throws IOExcepti ApplicationContext ctx = SecurityWebApplicationContextUtils .findRequiredWebApplicationContext(getServletContext()); Map wipes = ctx.getBeansOfType(WebInvocationPrivilegeEvaluator.class); - if (wipes.size() == 0) { + if (wipes.isEmpty()) { throw new IOException( "No visible WebInvocationPrivilegeEvaluator instance could be found in the application " + "context. There must be at least one in order to support the use of URL access checks in 'authorize' tags."); diff --git a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AccessControlListTag.java b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AccessControlListTag.java index 9ca399425ec..bfe26d073fd 100644 --- a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AccessControlListTag.java +++ b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AccessControlListTag.java @@ -163,7 +163,7 @@ private T getBeanOfType(Class type) throws JspException { .getParent()) { map.putAll(context.getBeansOfType(type)); } - if (map.size() == 0) { + if (map.isEmpty()) { return null; } if (map.size() == 1) { diff --git a/web/src/main/java/org/springframework/security/web/FilterChainProxy.java b/web/src/main/java/org/springframework/security/web/FilterChainProxy.java index 90a26baaaca..7795f2c8bac 100644 --- a/web/src/main/java/org/springframework/security/web/FilterChainProxy.java +++ b/web/src/main/java/org/springframework/security/web/FilterChainProxy.java @@ -211,7 +211,7 @@ private void doFilterInternal(ServletRequest request, ServletResponse response, FirewalledRequest firewallRequest = this.firewall.getFirewalledRequest((HttpServletRequest) request); HttpServletResponse firewallResponse = this.firewall.getFirewalledResponse((HttpServletResponse) response); List filters = getFilters(firewallRequest); - if (filters == null || filters.size() == 0) { + if (filters == null || filters.isEmpty()) { if (logger.isTraceEnabled()) { logger.trace(LogMessage.of(() -> "No security for " + requestLine(firewallRequest))); }