From 578d6287748503550d3d6f6655a5d34affe87f3d Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Fri, 9 Aug 2019 00:58:17 +0200 Subject: [PATCH] 'Collection.toArray()' call style --- .../provisioning/JdbcUserDetailsManagerConfigurer.java | 2 +- .../method/configuration/ReactiveMethodSecuritySelector.java | 2 +- .../config/annotation/web/configurers/LogoutConfigurer.java | 2 +- .../security/ldap/DefaultSpringSecurityContextSource.java | 2 +- .../security/ldap/userdetails/LdapUserDetailsManager.java | 2 +- .../ldap/userdetails/NestedLdapAuthoritiesPopulator.java | 2 +- .../org/springframework/security/ldap/userdetails/Person.java | 2 +- .../security/web/authentication/www/DigestAuthUtils.java | 2 +- .../security/web/savedrequest/SavedRequestAwareWrapper.java | 2 +- .../springframework/security/web/util/ThrowableAnalyzer.java | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/provisioning/JdbcUserDetailsManagerConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/provisioning/JdbcUserDetailsManagerConfigurer.java index 69052f4925..e1af639341 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/provisioning/JdbcUserDetailsManagerConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/provisioning/JdbcUserDetailsManagerConfigurer.java @@ -191,7 +191,7 @@ public class JdbcUserDetailsManagerConfigurer result = new ArrayList<>(); result.add(AutoProxyRegistrar.class.getName()); result.add(ReactiveMethodSecurityConfiguration.class.getName()); - return result.toArray(new String[result.size()]); + return result.toArray(new String[0]); } } diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java index 2f90007958..d919bfd71d 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java @@ -330,7 +330,7 @@ public final class LogoutConfigurer> extends private LogoutFilter createLogoutFilter(H http) throws Exception { logoutHandlers.add(contextLogoutHandler); LogoutHandler[] handlers = logoutHandlers - .toArray(new LogoutHandler[logoutHandlers.size()]); + .toArray(new LogoutHandler[0]); LogoutFilter result = new LogoutFilter(getLogoutSuccessHandler(), handlers); result.setLogoutRequestMatcher(getLogoutRequestMatcher(http)); result = postProcess(result); diff --git a/ldap/src/main/java/org/springframework/security/ldap/DefaultSpringSecurityContextSource.java b/ldap/src/main/java/org/springframework/security/ldap/DefaultSpringSecurityContextSource.java index 6adc0bc2cd..f9790d606d 100644 --- a/ldap/src/main/java/org/springframework/security/ldap/DefaultSpringSecurityContextSource.java +++ b/ldap/src/main/java/org/springframework/security/ldap/DefaultSpringSecurityContextSource.java @@ -84,7 +84,7 @@ public class DefaultSpringSecurityContextSource extends LdapContextSource { } } - setUrls(urls.toArray(new String[urls.size()])); + setUrls(urls.toArray(new String[0])); setBase(this.rootDn); setPooled(true); setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy() { diff --git a/ldap/src/main/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManager.java b/ldap/src/main/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManager.java index 626a06ac19..e90831e8c4 100644 --- a/ldap/src/main/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManager.java +++ b/ldap/src/main/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManager.java @@ -271,7 +271,7 @@ public class LdapUserDetailsManager implements UserDetailsManager { } } - template.modifyAttributes(dn, mods.toArray(new ModificationItem[mods.size()])); + template.modifyAttributes(dn, mods.toArray(new ModificationItem[0])); // template.rebind(dn, ctx, null); // Remove the old authorities and replace them with the new one diff --git a/ldap/src/main/java/org/springframework/security/ldap/userdetails/NestedLdapAuthoritiesPopulator.java b/ldap/src/main/java/org/springframework/security/ldap/userdetails/NestedLdapAuthoritiesPopulator.java index d92ceeee8c..07e37b4cef 100644 --- a/ldap/src/main/java/org/springframework/security/ldap/userdetails/NestedLdapAuthoritiesPopulator.java +++ b/ldap/src/main/java/org/springframework/security/ldap/userdetails/NestedLdapAuthoritiesPopulator.java @@ -201,7 +201,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula .searchForMultipleAttributeValues(getGroupSearchBase(), getGroupSearchFilter(), new String[] { userDn, username }, getAttributeNames() - .toArray(new String[getAttributeNames().size()])); + .toArray(new String[0])); if (logger.isDebugEnabled()) { logger.debug("Roles from search: " + userRoles); diff --git a/ldap/src/main/java/org/springframework/security/ldap/userdetails/Person.java b/ldap/src/main/java/org/springframework/security/ldap/userdetails/Person.java index 899d189da3..f68f5a6736 100644 --- a/ldap/src/main/java/org/springframework/security/ldap/userdetails/Person.java +++ b/ldap/src/main/java/org/springframework/security/ldap/userdetails/Person.java @@ -56,7 +56,7 @@ public class Person extends LdapUserDetailsImpl { } public String[] getCn() { - return cn.toArray(new String[cn.size()]); + return cn.toArray(new String[0]); } public String getDescription() { diff --git a/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthUtils.java b/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthUtils.java index 5bd9931f3e..df246a3edf 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthUtils.java +++ b/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthUtils.java @@ -80,7 +80,7 @@ final class DigestAuthUtils { list.add(str.substring(start, i)); } - return list.toArray(new String[list.size()]); + return list.toArray(new String[0]); } /** diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapper.java b/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapper.java index ea6d429642..b2761b7127 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapper.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapper.java @@ -248,6 +248,6 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper { } } - return combinedParams.toArray(new String[combinedParams.size()]); + return combinedParams.toArray(new String[0]); } } diff --git a/web/src/main/java/org/springframework/security/web/util/ThrowableAnalyzer.java b/web/src/main/java/org/springframework/security/web/util/ThrowableAnalyzer.java index e1cf919724..2c3c24f909 100755 --- a/web/src/main/java/org/springframework/security/web/util/ThrowableAnalyzer.java +++ b/web/src/main/java/org/springframework/security/web/util/ThrowableAnalyzer.java @@ -138,7 +138,7 @@ public class ThrowableAnalyzer { @SuppressWarnings("unchecked") final Class[] getRegisteredTypes() { Set> typeList = this.extractorMap.keySet(); - return typeList.toArray(new Class[typeList.size()]); + return typeList.toArray(new Class[0]); } /** @@ -171,7 +171,7 @@ public class ThrowableAnalyzer { currentThrowable = extractCause(currentThrowable); } - return chain.toArray(new Throwable[chain.size()]); + return chain.toArray(new Throwable[0]); } /**