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.
|
||||
@@ -253,8 +253,8 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
|
||||
Element aspectElement, String aspectId, List<BeanDefinition> beanDefs,
|
||||
List<BeanReference> beanRefs, ParserContext parserContext) {
|
||||
|
||||
BeanDefinition[] beanDefArray = beanDefs.toArray(new BeanDefinition[beanDefs.size()]);
|
||||
BeanReference[] beanRefArray = beanRefs.toArray(new BeanReference[beanRefs.size()]);
|
||||
BeanDefinition[] beanDefArray = beanDefs.toArray(new BeanDefinition[0]);
|
||||
BeanReference[] beanRefArray = beanRefs.toArray(new BeanReference[0]);
|
||||
Object source = parserContext.extractSource(aspectElement);
|
||||
return new AspectComponentDefinition(aspectId, beanDefArray, beanRefArray, source);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -228,7 +228,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||
|
||||
@Override
|
||||
public Class<?>[] getProxiedInterfaces() {
|
||||
return this.interfaces.toArray(new Class<?>[this.interfaces.size()]);
|
||||
return ClassUtils.toClassArray(this.interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -372,7 +372,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||
* Bring the array up to date with the list.
|
||||
*/
|
||||
protected final void updateAdvisorArray() {
|
||||
this.advisorArray = this.advisors.toArray(new Advisor[this.advisors.size()]);
|
||||
this.advisorArray = this.advisors.toArray(new Advisor[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.
|
||||
@@ -90,7 +90,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
|
||||
if (interceptors.isEmpty()) {
|
||||
throw new UnknownAdviceTypeException(advisor.getAdvice());
|
||||
}
|
||||
return interceptors.toArray(new MethodInterceptor[interceptors.size()]);
|
||||
return interceptors.toArray(new MethodInterceptor[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -554,7 +554,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||
advisors.add(this.advisorAdapterRegistry.wrap(next));
|
||||
}
|
||||
}
|
||||
return advisors.toArray(new Advisor[advisors.size()]);
|
||||
return advisors.toArray(new Advisor[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.
|
||||
@@ -105,7 +105,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||
|
||||
@Override
|
||||
public Class<?>[] getInterfaces() {
|
||||
return this.interfaces.toArray(new Class<?>[this.interfaces.size()]);
|
||||
return ClassUtils.toClassArray(this.interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,7 +61,7 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable {
|
||||
|
||||
@Override
|
||||
public Class<?>[] getInterfaces() {
|
||||
return this.publishedInterfaces.toArray(new Class<?>[this.publishedInterfaces.size()]);
|
||||
return ClassUtils.toClassArray(this.publishedInterfaces);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -118,8 +118,7 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl
|
||||
|
||||
// If we encountered individual exceptions, throw the composite exception.
|
||||
if (propertyAccessExceptions != null) {
|
||||
PropertyAccessException[] paeArray =
|
||||
propertyAccessExceptions.toArray(new PropertyAccessException[propertyAccessExceptions.size()]);
|
||||
PropertyAccessException[] paeArray = propertyAccessExceptions.toArray(new PropertyAccessException[0]);
|
||||
throw new PropertyBatchUpdateException(paeArray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -220,7 +220,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
*/
|
||||
@Override
|
||||
public PropertyDescriptor[] getPropertyDescriptors() {
|
||||
return this.propertyDescriptors.toArray(new PropertyDescriptor[this.propertyDescriptors.size()]);
|
||||
return this.propertyDescriptors.toArray(new PropertyDescriptor[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
@@ -246,7 +246,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
|
||||
|
||||
@Override
|
||||
public PropertyValue[] getPropertyValues() {
|
||||
return this.propertyValueList.toArray(new PropertyValue[this.propertyValueList.size()]);
|
||||
return this.propertyValueList.toArray(new PropertyValue[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
@@ -149,7 +149,7 @@ public class BeanCreationException extends FatalBeanException {
|
||||
if (this.relatedCauses == null) {
|
||||
return null;
|
||||
}
|
||||
return this.relatedCauses.toArray(new Throwable[this.relatedCauses.size()]);
|
||||
return this.relatedCauses.toArray(new Throwable[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
"default constructor to fall back to: " + candidates.get(0));
|
||||
}
|
||||
}
|
||||
candidateConstructors = candidates.toArray(new Constructor<?>[candidates.size()]);
|
||||
candidateConstructors = candidates.toArray(new Constructor<?>[0]);
|
||||
}
|
||||
else if (rawCandidates.length == 1 && rawCandidates[0].getParameterCount() > 0) {
|
||||
candidateConstructors = new Constructor<?>[] {rawCandidates[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.
|
||||
@@ -83,8 +83,8 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com
|
||||
references.add((BeanReference) value);
|
||||
}
|
||||
}
|
||||
this.innerBeanDefinitions = innerBeans.toArray(new BeanDefinition[innerBeans.size()]);
|
||||
this.beanReferences = references.toArray(new BeanReference[references.size()]);
|
||||
this.innerBeanDefinitions = innerBeans.toArray(new BeanDefinition[0]);
|
||||
this.beanReferences = references.toArray(new BeanReference[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.
|
||||
@@ -79,7 +79,7 @@ public class CompositeComponentDefinition extends AbstractComponentDefinition {
|
||||
* @return the array of nested components, or an empty array if none
|
||||
*/
|
||||
public ComponentDefinition[] getNestedComponents() {
|
||||
return this.nestedComponents.toArray(new ComponentDefinition[this.nestedComponents.size()]);
|
||||
return this.nestedComponents.toArray(new ComponentDefinition[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.
|
||||
@@ -29,7 +29,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -1496,15 +1495,9 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @see #isExcludedFromDependencyCheck
|
||||
*/
|
||||
protected PropertyDescriptor[] filterPropertyDescriptorsForDependencyCheck(BeanWrapper bw) {
|
||||
List<PropertyDescriptor> pds =
|
||||
new LinkedList<>(Arrays.asList(bw.getPropertyDescriptors()));
|
||||
for (Iterator<PropertyDescriptor> it = pds.iterator(); it.hasNext();) {
|
||||
PropertyDescriptor pd = it.next();
|
||||
if (isExcludedFromDependencyCheck(pd)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return pds.toArray(new PropertyDescriptor[pds.size()]);
|
||||
List<PropertyDescriptor> pds = new LinkedList<>(Arrays.asList(bw.getPropertyDescriptors()));
|
||||
pds.removeIf(this::isExcludedFromDependencyCheck);
|
||||
return pds.toArray(new PropertyDescriptor[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.
|
||||
@@ -419,7 +419,7 @@ class ConstructorResolver {
|
||||
candidateSet.add(candidate);
|
||||
}
|
||||
}
|
||||
Method[] candidates = candidateSet.toArray(new Method[candidateSet.size()]);
|
||||
Method[] candidates = candidateSet.toArray(new Method[0]);
|
||||
AutowireUtils.sortFactoryMethods(candidates);
|
||||
|
||||
ConstructorArgumentValues resolvedValues = null;
|
||||
|
||||
@@ -1780,7 +1780,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
if (targetType != null && targetType != obj.getClass()) {
|
||||
sources.add(targetType);
|
||||
}
|
||||
return sources.toArray(new Object[sources.size()]);
|
||||
return sources.toArray();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -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.
|
||||
@@ -266,7 +266,7 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
|
||||
ele, ex);
|
||||
}
|
||||
}
|
||||
Resource[] actResArray = actualResources.toArray(new Resource[actualResources.size()]);
|
||||
Resource[] actResArray = actualResources.toArray(new Resource[0]);
|
||||
getReaderContext().fireImportProcessed(location, actResArray, extractSource(ele));
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -337,7 +337,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
|
||||
resolvedArgs.add(arg);
|
||||
}
|
||||
}
|
||||
return resolvedArgs.toArray(new Object[resolvedArgs.size()]);
|
||||
return resolvedArgs.toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -383,8 +383,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
|
||||
notificationListeners.add(bean);
|
||||
});
|
||||
|
||||
this.notificationListeners =
|
||||
notificationListeners.toArray(new NotificationListenerBean[notificationListeners.size()]);
|
||||
this.notificationListeners = notificationListeners.toArray(new NotificationListenerBean[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
@@ -87,7 +87,7 @@ public abstract class AbstractConfigurableMBeanInfoAssembler extends AbstractRef
|
||||
ManagedNotification mn = (ManagedNotification) colValue;
|
||||
result.add(JmxMetadataUtils.convertToModelMBeanNotificationInfo(mn));
|
||||
}
|
||||
return result.toArray(new ModelMBeanNotificationInfo[result.size()]);
|
||||
return result.toArray(new ModelMBeanNotificationInfo[0]);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(
|
||||
|
||||
@@ -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.
|
||||
@@ -333,7 +333,7 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean
|
||||
}
|
||||
}
|
||||
|
||||
return infos.toArray(new ModelMBeanAttributeInfo[infos.size()]);
|
||||
return infos.toArray(new ModelMBeanAttributeInfo[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,7 +401,7 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean
|
||||
}
|
||||
}
|
||||
|
||||
return infos.toArray(new ModelMBeanOperationInfo[infos.size()]);
|
||||
return infos.toArray(new ModelMBeanOperationInfo[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.
|
||||
@@ -228,7 +228,7 @@ public class MBeanRegistrationSupport {
|
||||
*/
|
||||
protected final ObjectName[] getRegisteredObjectNames() {
|
||||
synchronized (this.registeredBeans) {
|
||||
return this.registeredBeans.toArray(new ObjectName[this.registeredBeans.size()]);
|
||||
return this.registeredBeans.toArray(new ObjectName[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
package org.springframework.validation.beanvalidation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -37,6 +37,7 @@ import org.springframework.context.MessageSourceResolvable;
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.FieldError;
|
||||
@@ -116,7 +117,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
|
||||
}
|
||||
}
|
||||
processConstraintViolations(
|
||||
this.targetValidator.validate(target, groups.toArray(new Class<?>[groups.size()])), errors);
|
||||
this.targetValidator.validate(target, ClassUtils.toClassArray(groups)), errors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +242,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
|
||||
* @see org.springframework.validation.DefaultBindingErrorProcessor#getArgumentsForBindError
|
||||
*/
|
||||
protected Object[] getArgumentsForConstraint(String objectName, String field, ConstraintDescriptor<?> descriptor) {
|
||||
List<Object> arguments = new LinkedList<>();
|
||||
List<Object> arguments = new ArrayList<>();
|
||||
arguments.add(getResolvableField(objectName, field));
|
||||
// Using a TreeMap for alphabetical ordering of attribute names
|
||||
Map<String, Object> attributesToExpose = new TreeMap<>();
|
||||
@@ -254,7 +255,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
|
||||
}
|
||||
});
|
||||
arguments.addAll(attributesToExpose.values());
|
||||
return arguments.toArray(new Object[arguments.size()]);
|
||||
return arguments.toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -211,7 +211,7 @@ public final class Property {
|
||||
addAnnotationsToMap(annotationMap, getReadMethod());
|
||||
addAnnotationsToMap(annotationMap, getWriteMethod());
|
||||
addAnnotationsToMap(annotationMap, getField());
|
||||
annotations = annotationMap.values().toArray(new Annotation[annotationMap.size()]);
|
||||
annotations = annotationMap.values().toArray(new Annotation[0]);
|
||||
annotationCache.put(this, annotations);
|
||||
}
|
||||
return annotations;
|
||||
|
||||
@@ -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.
|
||||
@@ -320,7 +320,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Resolved classpath location [" + location + "] to resources " + result);
|
||||
}
|
||||
return result.toArray(new Resource[result.size()]);
|
||||
return result.toArray(new Resource[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -515,7 +515,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Resolved location pattern [" + locationPattern + "] to resources " + result);
|
||||
}
|
||||
return result.toArray(new Resource[result.size()]);
|
||||
return result.toArray(new Resource[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.
|
||||
@@ -162,7 +162,7 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
|
||||
Resource.class.getName() + "]: only location String and Resource object supported");
|
||||
}
|
||||
}
|
||||
super.setValue(merged.toArray(new Resource[merged.size()]));
|
||||
super.setValue(merged.toArray(new Resource[0]));
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
@@ -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.
|
||||
@@ -78,8 +78,7 @@ class RecursiveAnnotationArrayVisitor extends AbstractRecursiveAnnotationVisitor
|
||||
@Override
|
||||
public void visitEnd() {
|
||||
if (!this.allNestedAttributes.isEmpty()) {
|
||||
this.attributes.put(this.attributeName,
|
||||
this.allNestedAttributes.toArray(new AnnotationAttributes[this.allNestedAttributes.size()]));
|
||||
this.attributes.put(this.attributeName, this.allNestedAttributes.toArray(new AnnotationAttributes[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1058,18 +1058,15 @@ public abstract class ClassUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the given Collection into a Class array.
|
||||
* The Collection must contain Class elements only.
|
||||
* @param collection the Collection to copy
|
||||
* @return the Class array ({@code null} if the passed-in
|
||||
* Collection was {@code null})
|
||||
* Copy the given {@code Collection} into a {@code Class} array.
|
||||
* <p>The {@code Collection} must contain {@code Class} elements only.
|
||||
* @param collection the {@code Collection} to copy
|
||||
* @return the {@code Class} array
|
||||
* @since 3.1
|
||||
* @see StringUtils#toStringArray
|
||||
*/
|
||||
@Nullable
|
||||
public static Class<?>[] toClassArray(@Nullable Collection<Class<?>> collection) {
|
||||
if (collection == null) {
|
||||
return null;
|
||||
}
|
||||
return collection.toArray(new Class<?>[collection.size()]);
|
||||
public static Class<?>[] toClassArray(Collection<Class<?>> collection) {
|
||||
return collection.toArray(new Class<?>[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1104,8 +1101,7 @@ public abstract class ClassUtils {
|
||||
* @return all interfaces that the given object implements as an array
|
||||
*/
|
||||
public static Class<?>[] getAllInterfacesForClass(Class<?> clazz, @Nullable ClassLoader classLoader) {
|
||||
Set<Class<?>> ifcs = getAllInterfacesForClassAsSet(clazz, classLoader);
|
||||
return ifcs.toArray(new Class<?>[ifcs.size()]);
|
||||
return toClassArray(getAllInterfacesForClassAsSet(clazz, classLoader));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -584,7 +584,7 @@ public abstract class ReflectionUtils {
|
||||
public static Method[] getAllDeclaredMethods(Class<?> leafClass) {
|
||||
final List<Method> methods = new ArrayList<>(32);
|
||||
doWithMethods(leafClass, methods::add);
|
||||
return methods.toArray(new Method[methods.size()]);
|
||||
return methods.toArray(new Method[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,7 +620,7 @@ public abstract class ReflectionUtils {
|
||||
methods.add(method);
|
||||
}
|
||||
});
|
||||
return methods.toArray(new Method[methods.size()]);
|
||||
return methods.toArray(new Method[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.
|
||||
@@ -229,7 +229,7 @@ public class StopWatch {
|
||||
if (!this.keepTaskList) {
|
||||
throw new UnsupportedOperationException("Task info is not being kept!");
|
||||
}
|
||||
return this.taskList.toArray(new TaskInfo[this.taskList.size()]);
|
||||
return this.taskList.toArray(new TaskInfo[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -945,7 +945,7 @@ public abstract class StringUtils {
|
||||
* @return the {@code String} array
|
||||
*/
|
||||
public static String[] toStringArray(Collection<String> collection) {
|
||||
return collection.toArray(new String[collection.size()]);
|
||||
return collection.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -955,8 +955,7 @@ public abstract class StringUtils {
|
||||
* @return the {@code String} array
|
||||
*/
|
||||
public static String[] toStringArray(Enumeration<String> enumeration) {
|
||||
List<String> list = Collections.list(enumeration);
|
||||
return list.toArray(new String[list.size()]);
|
||||
return toStringArray(Collections.list(enumeration));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -17,9 +17,9 @@
|
||||
package org.springframework.expression.common;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Deque;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
@@ -128,7 +128,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
|
||||
}
|
||||
}
|
||||
|
||||
return expressions.toArray(new Expression[expressions.size()]);
|
||||
return expressions.toArray(new Expression[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.
|
||||
@@ -365,7 +365,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
}
|
||||
return new CompoundExpression(toPos(start.getStartPosition(),
|
||||
nodes.get(nodes.size() - 1).getEndPosition()),
|
||||
nodes.toArray(new SpelNodeImpl[nodes.size()]));
|
||||
nodes.toArray(new SpelNodeImpl[0]));
|
||||
}
|
||||
|
||||
// node : ((DOT dottedNode) | (SAFE_NAVI dottedNode) | nonDottedNode)+;
|
||||
@@ -443,7 +443,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
List<SpelNodeImpl> args = new ArrayList<>();
|
||||
consumeArguments(args);
|
||||
eatToken(TokenKind.RPAREN);
|
||||
return args.toArray(new SpelNodeImpl[args.size()]);
|
||||
return args.toArray(new SpelNodeImpl[0]);
|
||||
}
|
||||
|
||||
private void eatConstructorArgs(List<SpelNodeImpl> accumulatedArguments) {
|
||||
@@ -646,36 +646,33 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
// ',' - more expressions in this list
|
||||
// ':' - this is a map!
|
||||
if (peekToken(TokenKind.RCURLY)) { // list with one item in it
|
||||
List<SpelNodeImpl> listElements = new ArrayList<>();
|
||||
listElements.add(firstExpression);
|
||||
List<SpelNodeImpl> elements = new ArrayList<>();
|
||||
elements.add(firstExpression);
|
||||
closingCurly = eatToken(TokenKind.RCURLY);
|
||||
expr = new InlineList(toPos(t.startPos, closingCurly.endPos),
|
||||
listElements.toArray(new SpelNodeImpl[listElements.size()]));
|
||||
expr = new InlineList(toPos(t.startPos, closingCurly.endPos), elements.toArray(new SpelNodeImpl[0]));
|
||||
}
|
||||
else if (peekToken(TokenKind.COMMA, true)) { // multi-item list
|
||||
List<SpelNodeImpl> listElements = new ArrayList<>();
|
||||
listElements.add(firstExpression);
|
||||
List<SpelNodeImpl> elements = new ArrayList<>();
|
||||
elements.add(firstExpression);
|
||||
do {
|
||||
listElements.add(eatExpression());
|
||||
elements.add(eatExpression());
|
||||
}
|
||||
while (peekToken(TokenKind.COMMA, true));
|
||||
closingCurly = eatToken(TokenKind.RCURLY);
|
||||
expr = new InlineList(toPos(t.startPos, closingCurly.endPos),
|
||||
listElements.toArray(new SpelNodeImpl[listElements.size()]));
|
||||
expr = new InlineList(toPos(t.startPos, closingCurly.endPos), elements.toArray(new SpelNodeImpl[0]));
|
||||
|
||||
}
|
||||
else if (peekToken(TokenKind.COLON, true)) { // map!
|
||||
List<SpelNodeImpl> mapElements = new ArrayList<>();
|
||||
mapElements.add(firstExpression);
|
||||
mapElements.add(eatExpression());
|
||||
List<SpelNodeImpl> elements = new ArrayList<>();
|
||||
elements.add(firstExpression);
|
||||
elements.add(eatExpression());
|
||||
while (peekToken(TokenKind.COMMA, true)) {
|
||||
mapElements.add(eatExpression());
|
||||
elements.add(eatExpression());
|
||||
eatToken(TokenKind.COLON);
|
||||
mapElements.add(eatExpression());
|
||||
elements.add(eatExpression());
|
||||
}
|
||||
closingCurly = eatToken(TokenKind.RCURLY);
|
||||
expr = new InlineMap(toPos(t.startPos, closingCurly.endPos),
|
||||
mapElements.toArray(new SpelNodeImpl[mapElements.size()]));
|
||||
expr = new InlineMap(toPos(t.startPos, closingCurly.endPos), elements.toArray(new SpelNodeImpl[0]));
|
||||
}
|
||||
else {
|
||||
throw internalException(t.startPos, SpelMessage.OOD);
|
||||
@@ -743,10 +740,8 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
throw internalException(node.startPos, SpelMessage.NOT_EXPECTED_TOKEN,
|
||||
"qualified ID", node.getKind().toString().toLowerCase());
|
||||
}
|
||||
int pos = toPos(qualifiedIdPieces.getFirst().getStartPosition(),
|
||||
qualifiedIdPieces.getLast().getEndPosition());
|
||||
return new QualifiedIdentifier(pos,
|
||||
qualifiedIdPieces.toArray(new SpelNodeImpl[qualifiedIdPieces.size()]));
|
||||
int pos = toPos(qualifiedIdPieces.getFirst().getStartPosition(), qualifiedIdPieces.getLast().getEndPosition());
|
||||
return new QualifiedIdentifier(pos, qualifiedIdPieces.toArray(new SpelNodeImpl[0]));
|
||||
}
|
||||
|
||||
private boolean isValidQualifiedId(@Nullable Token node) {
|
||||
@@ -812,15 +807,13 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
nodes.add(pop());
|
||||
}
|
||||
push(new ConstructorReference(toPos(newToken),
|
||||
dimensions.toArray(new SpelNodeImpl[dimensions.size()]),
|
||||
nodes.toArray(new SpelNodeImpl[nodes.size()])));
|
||||
dimensions.toArray(new SpelNodeImpl[0]), nodes.toArray(new SpelNodeImpl[0])));
|
||||
}
|
||||
else {
|
||||
// regular constructor invocation
|
||||
eatConstructorArgs(nodes);
|
||||
// TODO correct end position?
|
||||
push(new ConstructorReference(toPos(newToken),
|
||||
nodes.toArray(new SpelNodeImpl[nodes.size()])));
|
||||
push(new ConstructorReference(toPos(newToken), nodes.toArray(new SpelNodeImpl[0])));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SortedResourcesFactoryBean extends AbstractFactoryBean<Resource[]>
|
||||
});
|
||||
scripts.addAll(resources);
|
||||
}
|
||||
return scripts.toArray(new Resource[scripts.size()]);
|
||||
return scripts.toArray(new Resource[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.
|
||||
@@ -462,8 +462,8 @@ public abstract class AbstractJdbcInsert {
|
||||
// clause while HSQL uses a second query that has to be executed with the same connection.
|
||||
|
||||
if (keyQuery.toUpperCase().startsWith("RETURNING")) {
|
||||
Long key = getJdbcTemplate().queryForObject(getInsertString() + " " + keyQuery,
|
||||
values.toArray(new Object[values.size()]), Long.class);
|
||||
Long key = getJdbcTemplate().queryForObject(
|
||||
getInsertString() + " " + keyQuery, values.toArray(), Long.class);
|
||||
Map<String, Object> keys = new HashMap<>(1);
|
||||
keys.put(getGeneratedKeyNames()[0], key);
|
||||
keyHolder.getKeyList().add(keys);
|
||||
|
||||
@@ -41,6 +41,7 @@ import javax.jms.TopicSession;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -254,10 +255,8 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
|
||||
if (target instanceof TopicSession) {
|
||||
classes.add(TopicSession.class);
|
||||
}
|
||||
return (Session) Proxy.newProxyInstance(
|
||||
SessionProxy.class.getClassLoader(),
|
||||
classes.toArray(new Class<?>[classes.size()]),
|
||||
new CachedSessionInvocationHandler(target, sessionList));
|
||||
return (Session) Proxy.newProxyInstance(SessionProxy.class.getClassLoader(),
|
||||
ClassUtils.toClassArray(classes), new CachedSessionInvocationHandler(target, sessionList));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -48,7 +48,7 @@ public class ChainedExceptionListener implements ExceptionListener {
|
||||
* Return all registered ExceptionListener delegates (as array).
|
||||
*/
|
||||
public final ExceptionListener[] getDelegates() {
|
||||
return this.delegates.toArray(new ExceptionListener[this.delegates.size()]);
|
||||
return this.delegates.toArray(new ExceptionListener[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.
|
||||
@@ -42,6 +42,7 @@ import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* A JMS ConnectionFactory adapter that returns the same Connection
|
||||
@@ -519,10 +520,8 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
|
||||
if (target instanceof TopicConnection) {
|
||||
classes.add(TopicConnection.class);
|
||||
}
|
||||
return (Connection) Proxy.newProxyInstance(
|
||||
Connection.class.getClassLoader(),
|
||||
classes.toArray(new Class<?>[classes.size()]),
|
||||
new SharedConnectionInvocationHandler());
|
||||
return (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(),
|
||||
ClassUtils.toClassArray(classes), new SharedConnectionInvocationHandler());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -37,6 +37,7 @@ import javax.jms.TransactionInProgressException;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Proxy for a target JMS {@link javax.jms.ConnectionFactory}, adding awareness of
|
||||
@@ -229,10 +230,8 @@ public class TransactionAwareConnectionFactoryProxy
|
||||
if (target instanceof TopicConnection) {
|
||||
classes.add(TopicConnection.class);
|
||||
}
|
||||
return (Connection) Proxy.newProxyInstance(
|
||||
Connection.class.getClassLoader(),
|
||||
classes.toArray(new Class<?>[classes.size()]),
|
||||
new TransactionAwareConnectionInvocationHandler(target));
|
||||
return (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(),
|
||||
ClassUtils.toClassArray(classes), new TransactionAwareConnectionInvocationHandler(target));
|
||||
}
|
||||
|
||||
|
||||
@@ -301,10 +300,8 @@ public class TransactionAwareConnectionFactoryProxy
|
||||
if (target instanceof TopicSession) {
|
||||
classes.add(TopicSession.class);
|
||||
}
|
||||
return (Session) Proxy.newProxyInstance(
|
||||
SessionProxy.class.getClassLoader(),
|
||||
classes.toArray(new Class<?>[classes.size()]),
|
||||
new CloseSuppressingSessionInvocationHandler(target));
|
||||
return (Session) Proxy.newProxyInstance(SessionProxy.class.getClassLoader(),
|
||||
ClassUtils.toClassArray(classes), new CloseSuppressingSessionInvocationHandler(target));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -418,9 +418,8 @@ public abstract class AbstractEntityManagerFactoryBean implements
|
||||
}
|
||||
ifcs.add(EntityManagerFactoryInfo.class);
|
||||
try {
|
||||
return (EntityManagerFactory) Proxy.newProxyInstance(
|
||||
this.beanClassLoader, ifcs.toArray(new Class<?>[ifcs.size()]),
|
||||
new ManagedEntityManagerFactoryInvocationHandler(this));
|
||||
return (EntityManagerFactory) Proxy.newProxyInstance(this.beanClassLoader,
|
||||
ClassUtils.toClassArray(ifcs), new ManagedEntityManagerFactoryInvocationHandler(this));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
if (entityManagerFactoryInterface != null) {
|
||||
|
||||
@@ -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.
|
||||
@@ -232,7 +232,7 @@ public abstract class ExtendedEntityManagerCreator {
|
||||
ifcs.add(EntityManagerProxy.class);
|
||||
return (EntityManager) Proxy.newProxyInstance(
|
||||
(cl != null ? cl : ExtendedEntityManagerCreator.class.getClassLoader()),
|
||||
ifcs.toArray(new Class<?>[ifcs.size()]),
|
||||
ClassUtils.toClassArray(ifcs),
|
||||
new ExtendedEntityManagerInvocationHandler(
|
||||
rawEm, exceptionTranslator, jta, containerManaged, synchronizedWithTransaction));
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -150,7 +150,7 @@ final class PersistenceUnitReader {
|
||||
throw new IllegalArgumentException("Internal error parsing persistence unit from " + resourceLocation);
|
||||
}
|
||||
|
||||
return infos.toArray(new SpringPersistenceUnitInfo[infos.size()]);
|
||||
return infos.toArray(new SpringPersistenceUnitInfo[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.
|
||||
@@ -94,7 +94,7 @@ class ClassPathJaxb2TypeScanner {
|
||||
}
|
||||
}
|
||||
}
|
||||
return jaxb2Classes.toArray(new Class<?>[jaxb2Classes.size()]);
|
||||
return ClassUtils.toClassArray(jaxb2Classes);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new UncategorizedMappingException("Failed to scan classpath for unlisted classes", ex);
|
||||
|
||||
@@ -357,7 +357,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
}
|
||||
|
||||
public Cookie[] getCookies() {
|
||||
return this.cookies.toArray(new Cookie[this.cookies.size()]);
|
||||
return this.cookies.toArray(new Cookie[0]);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -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.
|
||||
@@ -149,7 +149,7 @@ public class TestContextManager {
|
||||
* @see #registerTestExecutionListeners(TestExecutionListener...)
|
||||
*/
|
||||
public void registerTestExecutionListeners(List<TestExecutionListener> testExecutionListeners) {
|
||||
registerTestExecutionListeners(testExecutionListeners.toArray(new TestExecutionListener[testExecutionListeners.size()]));
|
||||
registerTestExecutionListeners(testExecutionListeners.toArray(new TestExecutionListener[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.
|
||||
@@ -185,7 +185,7 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
|
||||
scriptResources.add(new ByteArrayResource(stmt.getBytes(), "from inlined SQL statement: " + stmt));
|
||||
}
|
||||
}
|
||||
populator.setScripts(scriptResources.toArray(new Resource[scriptResources.size()]));
|
||||
populator.setScripts(scriptResources.toArray(new Resource[0]));
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Executing SQL scripts: " + ObjectUtils.nullSafeToString(scriptResources));
|
||||
}
|
||||
|
||||
@@ -385,8 +385,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
|
||||
MergedTestPropertySources mergedTestPropertySources =
|
||||
TestPropertySourceUtils.buildMergedTestPropertySources(testClass);
|
||||
MergedContextConfiguration mergedConfig = new MergedContextConfiguration(testClass,
|
||||
StringUtils.toStringArray(locations),
|
||||
ClassUtils.toClassArray(classes),
|
||||
StringUtils.toStringArray(locations), ClassUtils.toClassArray(classes),
|
||||
ApplicationContextInitializerUtils.resolveInitializerClasses(configAttributesList),
|
||||
ActiveProfilesUtils.resolveActiveProfiles(testClass),
|
||||
mergedTestPropertySources.getLocations(),
|
||||
|
||||
@@ -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.
|
||||
@@ -28,6 +28,7 @@ import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.SmartContextLoader;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Utility methods for {@link SmartContextLoader SmartContextLoaders} that deal
|
||||
@@ -85,7 +86,7 @@ public abstract class AnnotationConfigContextLoaderUtils {
|
||||
}
|
||||
}
|
||||
|
||||
return configClasses.toArray(new Class<?>[configClasses.size()]);
|
||||
return ClassUtils.toClassArray(configClasses);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -29,6 +29,7 @@ import org.springframework.test.context.CacheAwareContextLoaderDelegate;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
import org.springframework.test.context.TestContext;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Default implementation of the {@link TestContext} interface.
|
||||
@@ -195,7 +196,7 @@ public class DefaultTestContext implements TestContext {
|
||||
@Override
|
||||
public String[] attributeNames() {
|
||||
synchronized (this.attributes) {
|
||||
return this.attributes.keySet().stream().toArray(String[]::new);
|
||||
return StringUtils.toStringArray(this.attributes.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -295,7 +295,7 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
||||
}
|
||||
|
||||
if (!ObjectUtils.isEmpty(cookies)) {
|
||||
request.setCookies(cookies.toArray(new Cookie[cookies.size()]));
|
||||
request.setCookies(cookies.toArray(new Cookie[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -652,7 +652,7 @@ public class MockHttpServletRequestBuilder
|
||||
}
|
||||
|
||||
if (!ObjectUtils.isEmpty(this.cookies)) {
|
||||
request.setCookies(this.cookies.toArray(new Cookie[this.cookies.size()]));
|
||||
request.setCookies(this.cookies.toArray(new Cookie[0]));
|
||||
}
|
||||
if (!ObjectUtils.isEmpty(this.locales)) {
|
||||
request.setPreferredLocales(this.locales);
|
||||
|
||||
@@ -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.
|
||||
@@ -25,6 +25,7 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.mock.web.MockServletConfig;
|
||||
import org.springframework.test.web.servlet.DispatcherServletCustomizer;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MockMvcBuilder;
|
||||
import org.springframework.test.web.servlet.MockMvcBuilderSupport;
|
||||
import org.springframework.test.web.servlet.RequestBuilder;
|
||||
import org.springframework.test.web.servlet.ResultHandler;
|
||||
@@ -34,7 +35,6 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.test.web.servlet.request.RequestPostProcessor;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.test.web.servlet.MockMvcBuilder;
|
||||
|
||||
/**
|
||||
* Abstract implementation of {@link MockMvcBuilder} with common methods for
|
||||
@@ -144,7 +144,7 @@ public abstract class AbstractMockMvcBuilder<B extends AbstractMockMvcBuilder<B>
|
||||
}
|
||||
}
|
||||
|
||||
Filter[] filterArray = this.filters.toArray(new Filter[this.filters.size()]);
|
||||
Filter[] filterArray = this.filters.toArray(new Filter[0]);
|
||||
|
||||
return super.createMockMvc(filterArray, mockServletConfig, wac, this.defaultRequestBuilder,
|
||||
this.globalResultMatchers, this.globalResultHandlers, this.dispatcherServletCustomizers);
|
||||
|
||||
@@ -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.
|
||||
@@ -50,7 +50,7 @@ public class ChainedPersistenceExceptionTranslator implements PersistenceExcepti
|
||||
* Return all registered PersistenceExceptionTranslator delegates (as array).
|
||||
*/
|
||||
public final PersistenceExceptionTranslator[] getDelegates() {
|
||||
return this.delegates.toArray(new PersistenceExceptionTranslator[this.delegates.size()]);
|
||||
return this.delegates.toArray(new PersistenceExceptionTranslator[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.
|
||||
@@ -103,7 +103,7 @@ final class DefaultSslInfo implements SslInfo {
|
||||
result.add((X509Certificate) certificate);
|
||||
}
|
||||
}
|
||||
return !result.isEmpty() ? result.toArray(new X509Certificate[result.size()]) : null;
|
||||
return (!result.isEmpty() ? result.toArray(new X509Certificate[0]) : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe
|
||||
logger.info("Registering annotated classes: [" +
|
||||
StringUtils.collectionToCommaDelimitedString(this.annotatedClasses) + "]");
|
||||
}
|
||||
reader.register(this.annotatedClasses.toArray(new Class<?>[this.annotatedClasses.size()]));
|
||||
reader.register(ClassUtils.toClassArray(this.annotatedClasses));
|
||||
}
|
||||
|
||||
if (!this.basePackages.isEmpty()) {
|
||||
|
||||
@@ -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.
|
||||
@@ -93,7 +93,7 @@ public abstract class MultipartResolutionDelegate {
|
||||
}
|
||||
if (multipartRequest != null) {
|
||||
List<MultipartFile> multipartFiles = multipartRequest.getFiles(name);
|
||||
return multipartFiles.toArray(new MultipartFile[multipartFiles.size()]);
|
||||
return multipartFiles.toArray(new MultipartFile[0]);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
@@ -164,7 +164,7 @@ public abstract class MultipartResolutionDelegate {
|
||||
result.add(part);
|
||||
}
|
||||
}
|
||||
return result.toArray(new Part[result.size()]);
|
||||
return result.toArray(new Part[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.
|
||||
@@ -21,14 +21,13 @@ import java.util.List;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebHandler;
|
||||
|
||||
/**
|
||||
* WebHandler decorator that invokes a chain of {@link WebFilter}s before the
|
||||
* delegate {@link WebHandler}.
|
||||
* {@link WebHandler} decorator that invokes a chain of {@link WebFilter}s
|
||||
* before the delegate {@link WebHandler}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
@@ -44,8 +43,7 @@ public class FilteringWebHandler extends WebHandlerDecorator {
|
||||
*/
|
||||
public FilteringWebHandler(WebHandler webHandler, List<WebFilter> filters) {
|
||||
super(webHandler);
|
||||
this.filters = !CollectionUtils.isEmpty(filters) ?
|
||||
filters.toArray(new WebFilter[filters.size()]) : new WebFilter[0];
|
||||
this.filters = filters.toArray(new WebFilter[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
}
|
||||
|
||||
public Cookie[] getCookies() {
|
||||
return this.cookies.toArray(new Cookie[this.cookies.size()]);
|
||||
return this.cookies.toArray(new Cookie[0]);
|
||||
}
|
||||
|
||||
public Cookie getCookie(String name) {
|
||||
|
||||
@@ -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.
|
||||
@@ -223,7 +223,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||
if (getResourceResolvers().get(i) instanceof PathResourceResolver) {
|
||||
PathResourceResolver resolver = (PathResourceResolver) getResourceResolvers().get(i);
|
||||
if (ObjectUtils.isEmpty(resolver.getAllowedLocations())) {
|
||||
resolver.setAllowedLocations(getLocations().toArray(new Resource[getLocations().size()]));
|
||||
resolver.setAllowedLocations(getLocations().toArray(new Resource[0]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -116,7 +116,7 @@ public class HandlerExecutionChain {
|
||||
@Nullable
|
||||
public HandlerInterceptor[] getInterceptors() {
|
||||
if (this.interceptors == null && this.interceptorList != null) {
|
||||
this.interceptors = this.interceptorList.toArray(new HandlerInterceptor[this.interceptorList.size()]);
|
||||
this.interceptors = this.interceptorList.toArray(new HandlerInterceptor[0]);
|
||||
}
|
||||
return this.interceptors;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -317,8 +317,8 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||
*/
|
||||
@Nullable
|
||||
protected final HandlerInterceptor[] getAdaptedInterceptors() {
|
||||
int count = this.adaptedInterceptors.size();
|
||||
return (count > 0 ? this.adaptedInterceptors.toArray(new HandlerInterceptor[count]) : null);
|
||||
return (!this.adaptedInterceptors.isEmpty() ?
|
||||
this.adaptedInterceptors.toArray(new HandlerInterceptor[0]) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,14 +327,13 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||
*/
|
||||
@Nullable
|
||||
protected final MappedInterceptor[] getMappedInterceptors() {
|
||||
List<MappedInterceptor> mappedInterceptors = new ArrayList<>();
|
||||
List<MappedInterceptor> mappedInterceptors = new ArrayList<>(this.adaptedInterceptors.size());
|
||||
for (HandlerInterceptor interceptor : this.adaptedInterceptors) {
|
||||
if (interceptor instanceof MappedInterceptor) {
|
||||
mappedInterceptors.add((MappedInterceptor) interceptor);
|
||||
}
|
||||
}
|
||||
int count = mappedInterceptors.size();
|
||||
return (count > 0 ? mappedInterceptors.toArray(new MappedInterceptor[count]) : null);
|
||||
return (!mappedInterceptors.isEmpty() ? mappedInterceptors.toArray(new MappedInterceptor[0]) : null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -47,7 +47,6 @@ import org.springframework.http.converter.support.AllEncompassingFormHttpMessage
|
||||
import org.springframework.http.converter.xml.SourceHttpMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ReflectionUtils.MethodFilter;
|
||||
import org.springframework.web.accept.ContentNegotiationManager;
|
||||
@@ -151,7 +150,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
|
||||
private DeferredResultProcessingInterceptor[] deferredResultInterceptors = new DeferredResultProcessingInterceptor[0];
|
||||
|
||||
private ReactiveAdapterRegistry reactiveRegistry = ReactiveAdapterRegistry.getSharedInstance();
|
||||
private ReactiveAdapterRegistry reactiveAdapterRegistry = ReactiveAdapterRegistry.getSharedInstance();
|
||||
|
||||
private boolean ignoreDefaultModelOnRedirect = false;
|
||||
|
||||
@@ -410,8 +409,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
* @param interceptors the interceptors to register
|
||||
*/
|
||||
public void setCallableInterceptors(List<CallableProcessingInterceptor> interceptors) {
|
||||
Assert.notNull(interceptors, "CallableProcessingInterceptor List must not be null");
|
||||
this.callableInterceptors = interceptors.toArray(new CallableProcessingInterceptor[interceptors.size()]);
|
||||
this.callableInterceptors = interceptors.toArray(new CallableProcessingInterceptor[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -419,18 +417,27 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
* @param interceptors the interceptors to register
|
||||
*/
|
||||
public void setDeferredResultInterceptors(List<DeferredResultProcessingInterceptor> interceptors) {
|
||||
Assert.notNull(interceptors, "DeferredResultProcessingInterceptor List must not be null");
|
||||
this.deferredResultInterceptors = interceptors.toArray(new DeferredResultProcessingInterceptor[interceptors.size()]);
|
||||
this.deferredResultInterceptors = interceptors.toArray(new DeferredResultProcessingInterceptor[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the registry for reactive library types to be supported as
|
||||
* return values from controller methods.
|
||||
* @since 5.0
|
||||
* @deprecated as of 5.0.5, in favor of {@link #setReactiveAdapterRegistry}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setReactiveRegistry(ReactiveAdapterRegistry reactiveRegistry) {
|
||||
Assert.notNull(reactiveRegistry, "ReactiveAdapterRegistry is required");
|
||||
this.reactiveRegistry = reactiveRegistry;
|
||||
this.reactiveAdapterRegistry = reactiveRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the registry for reactive library types to be supported as
|
||||
* return values from controller methods.
|
||||
* @since 5.0.5
|
||||
*/
|
||||
public void setReactiveAdapterRegistry(ReactiveAdapterRegistry reactiveAdapterRegistry) {
|
||||
this.reactiveAdapterRegistry = reactiveAdapterRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -438,7 +445,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
* @since 5.0
|
||||
*/
|
||||
public ReactiveAdapterRegistry getReactiveAdapterRegistry() {
|
||||
return this.reactiveRegistry;
|
||||
return this.reactiveAdapterRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -702,7 +709,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
handlers.add(new ModelMethodProcessor());
|
||||
handlers.add(new ViewMethodReturnValueHandler());
|
||||
handlers.add(new ResponseBodyEmitterReturnValueHandler(getMessageConverters(),
|
||||
this.reactiveRegistry, this.taskExecutor, this.contentNegotiationManager));
|
||||
this.reactiveAdapterRegistry, this.taskExecutor, this.contentNegotiationManager));
|
||||
handlers.add(new StreamingResponseBodyReturnValueHandler());
|
||||
handlers.add(new HttpEntityMethodProcessor(getMessageConverters(),
|
||||
this.contentNegotiationManager, this.requestResponseBodyAdvice));
|
||||
|
||||
@@ -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.
|
||||
@@ -387,7 +387,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
|
||||
if (getResourceResolvers().get(i) instanceof PathResourceResolver) {
|
||||
PathResourceResolver pathResolver = (PathResourceResolver) getResourceResolvers().get(i);
|
||||
if (ObjectUtils.isEmpty(pathResolver.getAllowedLocations())) {
|
||||
pathResolver.setAllowedLocations(getLocations().toArray(new Resource[getLocations().size()]));
|
||||
pathResolver.setAllowedLocations(getLocations().toArray(new Resource[0]));
|
||||
}
|
||||
if (this.urlPathHelper != null) {
|
||||
pathResolver.setLocationCharsets(this.locationCharsets);
|
||||
|
||||
@@ -180,7 +180,7 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration
|
||||
}
|
||||
ClassLoader classLoader = getApplicationContext().getClassLoader();
|
||||
Assert.state(classLoader != null, "No ClassLoader");
|
||||
return (!urls.isEmpty() ? new URLClassLoader(urls.toArray(new URL[urls.size()]), classLoader) : classLoader);
|
||||
return (!urls.isEmpty() ? new URLClassLoader(urls.toArray(new URL[0]), classLoader) : classLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -135,7 +135,7 @@ public abstract class AbstractWebSocketHandlerRegistration<M> implements WebSock
|
||||
List<HandshakeInterceptor> interceptors = new ArrayList<>(this.interceptors.size() + 1);
|
||||
interceptors.addAll(this.interceptors);
|
||||
interceptors.add(new OriginHandshakeInterceptor(this.allowedOrigins));
|
||||
return interceptors.toArray(new HandshakeInterceptor[interceptors.size()]);
|
||||
return interceptors.toArray(new HandshakeInterceptor[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,8 +62,8 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE
|
||||
private SockJsServiceRegistration registration;
|
||||
|
||||
|
||||
public WebMvcStompWebSocketEndpointRegistration(String[] paths, WebSocketHandler webSocketHandler,
|
||||
TaskScheduler sockJsTaskScheduler) {
|
||||
public WebMvcStompWebSocketEndpointRegistration(
|
||||
String[] paths, WebSocketHandler webSocketHandler, TaskScheduler sockJsTaskScheduler) {
|
||||
|
||||
Assert.notEmpty(paths, "No paths specified");
|
||||
Assert.notNull(webSocketHandler, "WebSocketHandler must not be null");
|
||||
@@ -76,7 +76,6 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE
|
||||
|
||||
@Override
|
||||
public StompWebSocketEndpointRegistration setHandshakeHandler(HandshakeHandler handshakeHandler) {
|
||||
Assert.notNull(handshakeHandler, "'handshakeHandler' must not be null");
|
||||
this.handshakeHandler = handshakeHandler;
|
||||
return this;
|
||||
}
|
||||
@@ -117,10 +116,10 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE
|
||||
}
|
||||
|
||||
protected HandshakeInterceptor[] getInterceptors() {
|
||||
List<HandshakeInterceptor> interceptors = new ArrayList<>();
|
||||
List<HandshakeInterceptor> interceptors = new ArrayList<>(this.interceptors.size() + 1);
|
||||
interceptors.addAll(this.interceptors);
|
||||
interceptors.add(new OriginHandshakeInterceptor(this.allowedOrigins));
|
||||
return interceptors.toArray(new HandshakeInterceptor[interceptors.size()]);
|
||||
return interceptors.toArray(new HandshakeInterceptor[0]);
|
||||
}
|
||||
|
||||
public final MultiValueMap<HttpRequestHandler, String> getMappings() {
|
||||
@@ -128,7 +127,7 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE
|
||||
if (this.registration != null) {
|
||||
SockJsService sockJsService = this.registration.getSockJsService();
|
||||
for (String path : this.paths) {
|
||||
String pattern = path.endsWith("/") ? path + "**" : path + "/**";
|
||||
String pattern = (path.endsWith("/") ? path + "**" : path + "/**");
|
||||
SockJsHttpRequestHandler handler = new SockJsHttpRequestHandler(sockJsService, this.webSocketHandler);
|
||||
mappings.add(handler, pattern);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user