Skip to content

Commit 8c1d06e

Browse files
committed
Polishing contribution
Closes gh-25927
1 parent 01892c6 commit 8c1d06e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,8 @@
2020
import java.io.IOException;
2121
import java.util.Arrays;
2222
import java.util.Collection;
23-
import java.util.HashSet;
23+
import java.util.Collections;
24+
import java.util.LinkedHashSet;
2425
import java.util.Set;
2526

2627
import org.apache.commons.logging.Log;
@@ -129,15 +130,15 @@ public void setAsText(String text) {
129130
public void setValue(Object value) throws IllegalArgumentException {
130131
if (value instanceof Collection || (value instanceof Object[] && !(value instanceof Resource[]))) {
131132
Collection<?> input = (value instanceof Collection ? (Collection<?>) value : Arrays.asList((Object[]) value));
132-
Set<Resource> merged = new HashSet<>(input.size());
133+
Set<Resource> merged = new LinkedHashSet<>();
133134
for (Object element : input) {
134135
if (element instanceof String) {
135136
// A location pattern: resolve it into a Resource array.
136137
// Might point to a single resource or to multiple resources.
137138
String pattern = resolvePath((String) element).trim();
138139
try {
139140
Resource[] resources = this.resourcePatternResolver.getResources(pattern);
140-
merged.addAll(Arrays.asList(resources));
141+
Collections.addAll(merged, resources);
141142
}
142143
catch (IOException ex) {
143144
// ignore - might be an unresolved placeholder or non-existing base directory

0 commit comments

Comments
 (0)