Consistent use of Collection.toArray with zero-sized array argument
Includes consistent use of ClassUtils.toClassArray (as non-null variant) Issue: SPR-16523
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -82,7 +82,7 @@ abstract class AbstractJCacheKeyOperation<A extends Annotation> extends Abstract
|
||||
}
|
||||
result.add(keyParameterDetail.toCacheInvocationParameter(values[parameterPosition]));
|
||||
}
|
||||
return result.toArray(new CacheInvocationParameter[result.size()]);
|
||||
return result.toArray(new CacheInvocationParameter[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -110,7 +110,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
||||
for (int i = 0; i < this.allParameterDetails.size(); i++) {
|
||||
result.add(this.allParameterDetails.get(i).toCacheInvocationParameter(values[i]));
|
||||
}
|
||||
return result.toArray(new CacheInvocationParameter[result.size()]);
|
||||
return result.toArray(new CacheInvocationParameter[0]);
|
||||
}
|
||||
|
||||
protected ExceptionTypeFilter createExceptionTypeFilter(
|
||||
|
||||
@@ -104,15 +104,14 @@ class KeyGeneratorAdapter implements KeyGenerator {
|
||||
parameters.add(value);
|
||||
}
|
||||
}
|
||||
return keyGenerator.generate(context.getTarget(), context.getMethod(),
|
||||
parameters.toArray(new Object[parameters.size()]));
|
||||
|
||||
return keyGenerator.generate(context.getTarget(), context.getMethod(), parameters.toArray());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private CacheKeyInvocationContext<?> createCacheKeyInvocationContext(Object target,
|
||||
JCacheOperation<?> operation, Object[] params) {
|
||||
private CacheKeyInvocationContext<?> createCacheKeyInvocationContext(
|
||||
Object target, JCacheOperation<?> operation, Object[] params) {
|
||||
|
||||
AbstractJCacheKeyOperation<Annotation> keyCacheOperation = (AbstractJCacheKeyOperation<Annotation>) operation;
|
||||
return new DefaultCacheKeyInvocationContext<>(keyCacheOperation, target, params);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -71,7 +71,7 @@ public class MailSendException extends MailException {
|
||||
public MailSendException(@Nullable String msg, @Nullable Throwable cause, Map<Object, Exception> failedMessages) {
|
||||
super(msg, cause);
|
||||
this.failedMessages = new LinkedHashMap<>(failedMessages);
|
||||
this.messageExceptions = failedMessages.values().toArray(new Exception[failedMessages.size()]);
|
||||
this.messageExceptions = failedMessages.values().toArray(new Exception[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -318,7 +318,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
simpleMessage.copyTo(message);
|
||||
mimeMessages.add(message.getMimeMessage());
|
||||
}
|
||||
doSend(mimeMessages.toArray(new MimeMessage[mimeMessages.size()]), simpleMessages);
|
||||
doSend(mimeMessages.toArray(new MimeMessage[0]), simpleMessages);
|
||||
}
|
||||
|
||||
|
||||
@@ -373,7 +373,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
preparator.prepare(mimeMessage);
|
||||
mimeMessages.add(mimeMessage);
|
||||
}
|
||||
send(mimeMessages.toArray(new MimeMessage[mimeMessages.size()]));
|
||||
send(mimeMessages.toArray(new MimeMessage[0]));
|
||||
}
|
||||
catch (MailException ex) {
|
||||
throw ex;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -390,15 +390,14 @@ public class FreeMarkerConfigurationFactory {
|
||||
*/
|
||||
@Nullable
|
||||
protected TemplateLoader getAggregateTemplateLoader(List<TemplateLoader> templateLoaders) {
|
||||
int loaderCount = templateLoaders.size();
|
||||
switch (loaderCount) {
|
||||
switch (templateLoaders.size()) {
|
||||
case 0:
|
||||
logger.info("No FreeMarker TemplateLoaders specified");
|
||||
return null;
|
||||
case 1:
|
||||
return templateLoaders.get(0);
|
||||
default:
|
||||
TemplateLoader[] loaders = templateLoaders.toArray(new TemplateLoader[loaderCount]);
|
||||
TemplateLoader[] loaders = templateLoaders.toArray(new TemplateLoader[0]);
|
||||
return new MultiTemplateLoader(loaders);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user