@ -18,10 +18,10 @@ package org.springframework.core.io.support;
import java.beans.PropertyEditorSupport ;
import java.beans.PropertyEditorSupport ;
import java.io.IOException ;
import java.io.IOException ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Arrays ;
import java.util.Collection ;
import java.util.Collection ;
import java.util.List ;
import java.util.HashSet ;
import java.util.Set ;
import org.apache.commons.logging.Log ;
import org.apache.commons.logging.Log ;
import org.apache.commons.logging.LogFactory ;
import org.apache.commons.logging.LogFactory ;
@ -129,7 +129,7 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
public void setValue ( Object value ) throws IllegalArgumentException {
public void setValue ( Object value ) throws IllegalArgumentException {
if ( value instanceof Collection | | ( value instanceof Object [ ] & & ! ( value instanceof Resource [ ] ) ) ) {
if ( value instanceof Collection | | ( value instanceof Object [ ] & & ! ( value instanceof Resource [ ] ) ) ) {
Collection < ? > input = ( value instanceof Collection ? ( Collection < ? > ) value : Arrays . asList ( ( Object [ ] ) value ) ) ;
Collection < ? > input = ( value instanceof Collection ? ( Collection < ? > ) value : Arrays . asList ( ( Object [ ] ) value ) ) ;
Lis t< Resource > merged = new ArrayLis t< > ( ) ;
Se t< Resource > merged = new HashSe t< > ( input . size ( ) ) ;
for ( Object element : input ) {
for ( Object element : input ) {
if ( element instanceof String ) {
if ( element instanceof String ) {
// A location pattern: resolve it into a Resource array.
// A location pattern: resolve it into a Resource array.
@ -137,11 +137,7 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
String pattern = resolvePath ( ( String ) element ) . trim ( ) ;
String pattern = resolvePath ( ( String ) element ) . trim ( ) ;
try {
try {
Resource [ ] resources = this . resourcePatternResolver . getResources ( pattern ) ;
Resource [ ] resources = this . resourcePatternResolver . getResources ( pattern ) ;
for ( Resource resource : resources ) {
merged . addAll ( Arrays . asList ( resources ) ) ;
if ( ! merged . contains ( resource ) ) {
merged . add ( resource ) ;
}
}
}
}
catch ( IOException ex ) {
catch ( IOException ex ) {
// ignore - might be an unresolved placeholder or non-existing base directory
// ignore - might be an unresolved placeholder or non-existing base directory
@ -152,10 +148,7 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
}
}
else if ( element instanceof Resource ) {
else if ( element instanceof Resource ) {
// A Resource object: add it to the result.
// A Resource object: add it to the result.
Resource resource = ( Resource ) element ;
merged . add ( ( Resource ) element ) ;
if ( ! merged . contains ( resource ) ) {
merged . add ( resource ) ;
}
}
}
else {
else {
throw new IllegalArgumentException ( "Cannot convert element [" + element + "] to [" +
throw new IllegalArgumentException ( "Cannot convert element [" + element + "] to [" +