Skip to content

Commit 04ab43d

Browse files
committed
Renaming + flattening streams
1 parent 54b5b6b commit 04ab43d

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

libs/entitlement/src/main/java/org/elasticsearch/entitlement/initialization/EntitlementInitialization.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import java.util.Map;
5252
import java.util.Set;
5353
import java.util.concurrent.ExecutorService;
54+
import java.util.function.Function;
5455
import java.util.stream.Collectors;
5556
import java.util.stream.Stream;
5657
import java.util.stream.StreamSupport;
@@ -71,7 +72,7 @@ public class EntitlementInitialization {
7172

7273
private static ElasticsearchEntitlementChecker manager;
7374

74-
interface InstrumentationInfoFunction {
75+
interface InstrumentationInfoFactory {
7576
InstrumentationService.InstrumentationInfo of(String methodName, Class<?>... parameterTypes) throws ClassNotFoundException,
7677
NoSuchMethodException;
7778
}
@@ -88,21 +89,21 @@ public static void initialize(Instrumentation inst) throws Exception {
8889
var latestCheckerInterface = getVersionSpecificCheckerClass(EntitlementChecker.class);
8990

9091
Map<MethodKey, CheckMethod> checkMethods = new HashMap<>(INSTRUMENTATION_SERVICE.lookupMethods(latestCheckerInterface));
91-
Stream.concat(
92+
Stream.of(
9293
fileSystemProviderChecks(),
93-
Stream.concat(
94-
fileStoreChecks(),
95-
Stream.of(
96-
INSTRUMENTATION_SERVICE.lookupImplementationMethod(
97-
SelectorProvider.class,
98-
"inheritedChannel",
99-
SelectorProvider.provider().getClass(),
100-
EntitlementChecker.class,
101-
"checkSelectorProviderInheritedChannel"
102-
)
94+
fileStoreChecks(),
95+
Stream.of(
96+
INSTRUMENTATION_SERVICE.lookupImplementationMethod(
97+
SelectorProvider.class,
98+
"inheritedChannel",
99+
SelectorProvider.provider().getClass(),
100+
EntitlementChecker.class,
101+
"checkSelectorProviderInheritedChannel"
103102
)
104103
)
105-
).forEach(instrumentation -> checkMethods.put(instrumentation.targetMethod(), instrumentation.checkMethod()));
104+
)
105+
.flatMap(Function.identity())
106+
.forEach(instrumentation -> checkMethods.put(instrumentation.targetMethod(), instrumentation.checkMethod()));
106107

107108
var classesToTransform = checkMethods.keySet().stream().map(MethodKey::className).collect(Collectors.toSet());
108109

@@ -161,7 +162,7 @@ private static Stream<InstrumentationService.InstrumentationInfo> fileSystemProv
161162
NoSuchMethodException {
162163
var fileSystemProviderClass = FileSystems.getDefault().provider().getClass();
163164

164-
var instrumentation = new InstrumentationInfoFunction() {
165+
var instrumentation = new InstrumentationInfoFactory() {
165166
@Override
166167
public InstrumentationService.InstrumentationInfo of(String methodName, Class<?>... parameterTypes)
167168
throws ClassNotFoundException, NoSuchMethodException {
@@ -211,7 +212,7 @@ private static Stream<InstrumentationService.InstrumentationInfo> fileStoreCheck
211212
.map(FileStore::getClass)
212213
.distinct();
213214
return fileStoreClasses.flatMap(fileStoreClass -> {
214-
var instrumentation = new InstrumentationInfoFunction() {
215+
var instrumentation = new InstrumentationInfoFactory() {
215216
@Override
216217
public InstrumentationService.InstrumentationInfo of(String methodName, Class<?>... parameterTypes)
217218
throws ClassNotFoundException, NoSuchMethodException {

0 commit comments

Comments
 (0)