Polish contribution
See gh-25367
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -712,10 +712,11 @@ public class Indexer extends SpelNodeImpl {
|
||||
}
|
||||
TypeDescriptor elementType = this.collectionEntryDescriptor.getElementTypeDescriptor();
|
||||
try {
|
||||
Constructor<?> ctor = getConstructor(elementType.getType());
|
||||
Constructor<?> ctor = getDefaultConstructor(elementType.getType());
|
||||
int newElements = this.index - this.collection.size();
|
||||
while (newElements >= 0) {
|
||||
this.collection.add(ctor == null ? null : ctor.newInstance());
|
||||
// Insert a null value if the element type does not have a default constructor.
|
||||
this.collection.add(ctor != null ? ctor.newInstance() : null);
|
||||
newElements--;
|
||||
}
|
||||
}
|
||||
@@ -725,7 +726,7 @@ public class Indexer extends SpelNodeImpl {
|
||||
}
|
||||
}
|
||||
|
||||
Constructor<?> getConstructor(Class<?> type) {
|
||||
private Constructor<?> getDefaultConstructor(Class<?> type) {
|
||||
try {
|
||||
return ReflectionUtils.accessibleConstructor(type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user