-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prune duplicate elements in resources
Prior to this commit a list with potential duplicates is generated and verified when loading the `junit-platform.properties` file. Addresses #2207
- Loading branch information
Showing
1 changed file
with
4 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,11 @@ | |
import java.net.URL; | ||
import java.net.URLConnection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Properties; | ||
import java.util.Set; | ||
|
||
import org.junit.platform.commons.logging.Logger; | ||
import org.junit.platform.commons.logging.LoggerFactory; | ||
|
@@ -52,7 +53,7 @@ private static Properties fromClasspathResource(String configFileName) { | |
|
||
try { | ||
ClassLoader classLoader = ClassLoaderUtils.getDefaultClassLoader(); | ||
List<URL> resources = Collections.list(classLoader.getResources(configFileName)); | ||
Set<URL> resources = new HashSet<>(Collections.list(classLoader.getResources(configFileName))); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
sormuras
Author
Member
|
||
|
||
if (!resources.isEmpty()) { | ||
if (resources.size() > 1) { | ||
|
@@ -61,7 +62,7 @@ private static Properties fromClasspathResource(String configFileName) { | |
resources.size(), configFileName)); | ||
} | ||
|
||
URL configFileUrl = resources.get(0); | ||
URL configFileUrl = resources.iterator().next(); // same as List#get(0) | ||
logger.info(() -> String.format( | ||
"Loading JUnit Platform configuration parameters from classpath resource [%s].", configFileUrl)); | ||
URLConnection urlConnection = configFileUrl.openConnection(); | ||
|
@sormuras This should be a
LinkedHashSet
to preserve the original order, shouldn't it?