Use Arrays.copyOf and Arrays.copyOfRange where possible

Closes gh-23393
This commit is contained in:
stsypanov
2019-07-31 19:17:22 +03:00
committed by Sam Brannen
parent 216ffcfe62
commit 78d56dc61b
5 changed files with 6 additions and 12 deletions

View File

@@ -180,8 +180,7 @@ public abstract class AopProxyUtils {
if (proxy instanceof DecoratingProxy) {
nonUserIfcCount++;
}
Class<?>[] userInterfaces = new Class<?>[proxyInterfaces.length - nonUserIfcCount];
System.arraycopy(proxyInterfaces, 0, userInterfaces, 0, userInterfaces.length);
Class<?>[] userInterfaces = Arrays.copyOf(proxyInterfaces, proxyInterfaces.length - nonUserIfcCount);
Assert.notEmpty(userInterfaces, "JDK proxy must implement one or more interfaces");
return userInterfaces;
}

View File

@@ -395,9 +395,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
logger.debug("Bean with name '" + finalName + "' concluding interceptor chain " +
"is not an advisor class: treating it as a target or TargetSource");
}
String[] newNames = new String[this.interceptorNames.length - 1];
System.arraycopy(this.interceptorNames, 0, newNames, 0, newNames.length);
this.interceptorNames = newNames;
this.interceptorNames = Arrays.copyOf(this.interceptorNames, this.interceptorNames.length - 1);
}
}
}