Remove duplicated elements in CorsConfiguration#combine()

Issue: SPR-14792
This commit is contained in:
Sebastien Deleuze
2016-10-11 10:06:17 +02:00
parent 196c73fa50
commit 9bf8489afd
2 changed files with 27 additions and 3 deletions

View File

@@ -18,7 +18,9 @@ package org.springframework.web.cors;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.springframework.http.HttpMethod;
import org.springframework.util.CollectionUtils;
@@ -123,12 +125,11 @@ public class CorsConfiguration {
if (source == null || source.contains(ALL)) {
return other;
}
List<String> combined = new ArrayList<>(source);
Set<String> combined = new LinkedHashSet<>(source);
combined.addAll(other);
return combined;
return new ArrayList<>(combined);
}
/**
* Set the origins to allow, e.g. {@code "http://domain1.com"}.
* <p>The special value {@code "*"} allows all domains.