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-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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user