From 8c1d06e0c42b0b6da30ea4f62b0c6988f360c43f Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 3 Dec 2020 17:15:18 +0000 Subject: [PATCH] Polishing contribution Closes gh-25927 --- .../core/io/support/ResourceArrayPropertyEditor.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java b/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java index 75e6754bee8..ec1c00c599b 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 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. @@ -20,7 +20,8 @@ import java.beans.PropertyEditorSupport; import java.io.IOException; import java.util.Arrays; import java.util.Collection; -import java.util.HashSet; +import java.util.Collections; +import java.util.LinkedHashSet; import java.util.Set; import org.apache.commons.logging.Log; @@ -129,7 +130,7 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport { public void setValue(Object value) throws IllegalArgumentException { if (value instanceof Collection || (value instanceof Object[] && !(value instanceof Resource[]))) { Collection input = (value instanceof Collection ? (Collection) value : Arrays.asList((Object[]) value)); - Set merged = new HashSet<>(input.size()); + Set merged = new LinkedHashSet<>(); for (Object element : input) { if (element instanceof String) { // A location pattern: resolve it into a Resource array. @@ -137,7 +138,7 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport { String pattern = resolvePath((String) element).trim(); try { Resource[] resources = this.resourcePatternResolver.getResources(pattern); - merged.addAll(Arrays.asList(resources)); + Collections.addAll(merged, resources); } catch (IOException ex) { // ignore - might be an unresolved placeholder or non-existing base directory