Use toUnmodifiableSet and toList instead of collectingAndThen

Since Spring Framework 6 uses JDK 17 for its baseline, we can make use
of toList() and toUnmodifiableSet() which were introduced in JDK 16 and
JDK 10, respectively.

Closes gh-27618
This commit is contained in:
최유진(Yujin Choi)/Platform Engineering팀/11ST 2021-10-28 10:58:11 +09:00 committed by Sam Brannen
parent 5ea1cf532e
commit 8dd385b440
2 changed files with 3 additions and 5 deletions

View File

@ -146,7 +146,7 @@ public abstract class YamlProcessor {
else {
Assert.noNullElements(supportedTypes, "'supportedTypes' must not contain null elements");
this.supportedTypes = Arrays.stream(supportedTypes).map(Class::getName)
.collect(Collectors.collectingAndThen(Collectors.toSet(), Collections::unmodifiableSet));
.collect(Collectors.toUnmodifiableSet());
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
@ -25,7 +25,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -157,8 +156,7 @@ public final class SpringFactoriesLoader {
}
// Replace all lists with unmodifiable lists containing unique elements
result.replaceAll((factoryType, implementations) -> implementations.stream().distinct()
.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)));
result.replaceAll((factoryType, implementations) -> implementations.stream().distinct().toList());
cache.put(classLoader, result);
}
catch (IOException ex) {