Use parenthesis with single-arg lambdas
Use regular expression search/replace to ensure all single-arg lambdas have parenthesis. This aligns with the style used in Spring Boot and ensure that single-arg and multi-arg lambdas are consistent. Issue gh-8945
This commit is contained in:
+1
-1
@@ -87,7 +87,7 @@ public class AnonymousPayloadInterceptor implements PayloadInterceptor, Ordered
|
||||
return chain.next(exchange)
|
||||
.subscriberContext(ReactiveSecurityContextHolder.withAuthentication(authentication))
|
||||
.then(Mono.empty());
|
||||
})).flatMap(securityContext -> chain.next(exchange));
|
||||
})).flatMap((securityContext) -> chain.next(exchange));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public class AuthenticationPayloadExchangeConverter implements PayloadExchangeAu
|
||||
return Mono
|
||||
.fromCallable(() -> this.metadataExtractor.extract(exchange.getPayload(),
|
||||
AuthenticationPayloadExchangeConverter.COMPOSITE_METADATA_MIME_TYPE))
|
||||
.flatMap(metadata -> Mono.justOrEmpty(authentication(metadata)));
|
||||
.flatMap((metadata) -> Mono.justOrEmpty(authentication(metadata)));
|
||||
}
|
||||
|
||||
private Authentication authentication(Map<String, Object> metadata) {
|
||||
|
||||
+2
-2
@@ -73,8 +73,8 @@ public class AuthenticationPayloadInterceptor implements PayloadInterceptor, Ord
|
||||
@Override
|
||||
public Mono<Void> intercept(PayloadExchange exchange, PayloadInterceptorChain chain) {
|
||||
return this.authenticationConverter.convert(exchange).switchIfEmpty(chain.next(exchange).then(Mono.empty()))
|
||||
.flatMap(a -> this.authenticationManager.authenticate(a))
|
||||
.flatMap(a -> onAuthenticationSuccess(chain.next(exchange), a));
|
||||
.flatMap((a) -> this.authenticationManager.authenticate(a))
|
||||
.flatMap((a) -> onAuthenticationSuccess(chain.next(exchange), a));
|
||||
}
|
||||
|
||||
private Mono<Void> onAuthenticationSuccess(Mono<Void> payload, Authentication authentication) {
|
||||
|
||||
+2
-2
@@ -47,10 +47,10 @@ public class BasicAuthenticationPayloadExchangeConverter implements PayloadExcha
|
||||
@Override
|
||||
public Mono<Authentication> convert(PayloadExchange exchange) {
|
||||
return Mono.fromCallable(() -> this.metadataExtractor.extract(exchange.getPayload(), this.metadataMimetype))
|
||||
.flatMap(metadata -> Mono
|
||||
.flatMap((metadata) -> Mono
|
||||
.justOrEmpty(metadata.get(UsernamePasswordMetadata.BASIC_AUTHENTICATION_MIME_TYPE.toString())))
|
||||
.cast(UsernamePasswordMetadata.class)
|
||||
.map(credentials -> new UsernamePasswordAuthenticationToken(credentials.getUsername(),
|
||||
.map((credentials) -> new UsernamePasswordAuthenticationToken(credentials.getUsername(),
|
||||
credentials.getPassword()));
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -56,11 +56,11 @@ public class AuthorizationPayloadInterceptor implements PayloadInterceptor, Orde
|
||||
|
||||
@Override
|
||||
public Mono<Void> intercept(PayloadExchange exchange, PayloadInterceptorChain chain) {
|
||||
return ReactiveSecurityContextHolder.getContext().filter(c -> c.getAuthentication() != null)
|
||||
return ReactiveSecurityContextHolder.getContext().filter((c) -> c.getAuthentication() != null)
|
||||
.map(SecurityContext::getAuthentication)
|
||||
.switchIfEmpty(Mono.error(() -> new AuthenticationCredentialsNotFoundException(
|
||||
"An Authentication (possibly AnonymousAuthenticationToken) is required.")))
|
||||
.as(authentication -> this.authorizationManager.verify(authentication, exchange))
|
||||
.as((authentication) -> this.authorizationManager.verify(authentication, exchange))
|
||||
.then(chain.next(exchange));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -52,9 +52,9 @@ public final class PayloadExchangeMatcherReactiveAuthorizationManager
|
||||
@Override
|
||||
public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, PayloadExchange exchange) {
|
||||
return Flux.fromIterable(this.mappings)
|
||||
.concatMap(mapping -> mapping.getMatcher().matches(exchange)
|
||||
.filter(PayloadExchangeMatcher.MatchResult::isMatch).map(r -> r.getVariables())
|
||||
.flatMap(variables -> mapping.getEntry().check(authentication,
|
||||
.concatMap((mapping) -> mapping.getMatcher().matches(exchange)
|
||||
.filter(PayloadExchangeMatcher.MatchResult::isMatch).map((r) -> r.getVariables())
|
||||
.flatMap((variables) -> mapping.getEntry().check(authentication,
|
||||
new PayloadExchangeAuthorizationContext(exchange, variables))))
|
||||
.next().switchIfEmpty(Mono.fromCallable(() -> new AuthorizationDecision(false)));
|
||||
}
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ class ContextPayloadInterceptorChain implements PayloadInterceptorChain {
|
||||
@Override
|
||||
public Mono<Void> next(PayloadExchange exchange) {
|
||||
return Mono.defer(() -> shouldIntercept() ? this.currentInterceptor.intercept(exchange, this.next)
|
||||
: Mono.subscriberContext().doOnNext(c -> this.context = c).then());
|
||||
: Mono.subscriberContext().doOnNext((c) -> this.context = c).then());
|
||||
}
|
||||
|
||||
Context getContext() {
|
||||
|
||||
+9
-9
@@ -72,37 +72,37 @@ class PayloadInterceptorRSocket extends RSocketProxy {
|
||||
@Override
|
||||
public Mono<Void> fireAndForget(Payload payload) {
|
||||
return intercept(PayloadExchangeType.FIRE_AND_FORGET, payload)
|
||||
.flatMap(context -> this.source.fireAndForget(payload).subscriberContext(context));
|
||||
.flatMap((context) -> this.source.fireAndForget(payload).subscriberContext(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Payload> requestResponse(Payload payload) {
|
||||
return intercept(PayloadExchangeType.REQUEST_RESPONSE, payload)
|
||||
.flatMap(context -> this.source.requestResponse(payload).subscriberContext(context));
|
||||
.flatMap((context) -> this.source.requestResponse(payload).subscriberContext(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<Payload> requestStream(Payload payload) {
|
||||
return intercept(PayloadExchangeType.REQUEST_STREAM, payload)
|
||||
.flatMapMany(context -> this.source.requestStream(payload).subscriberContext(context));
|
||||
.flatMapMany((context) -> this.source.requestStream(payload).subscriberContext(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<Payload> requestChannel(Publisher<Payload> payloads) {
|
||||
return Flux.from(payloads).switchOnFirst((signal, innerFlux) -> {
|
||||
Payload firstPayload = signal.get();
|
||||
return intercept(PayloadExchangeType.REQUEST_CHANNEL, firstPayload).flatMapMany(
|
||||
context -> innerFlux.skip(1).flatMap(p -> intercept(PayloadExchangeType.PAYLOAD, p).thenReturn(p))
|
||||
.transform(securedPayloads -> Flux.concat(Flux.just(firstPayload), securedPayloads))
|
||||
.transform(securedPayloads -> this.source.requestChannel(securedPayloads))
|
||||
.subscriberContext(context));
|
||||
return intercept(PayloadExchangeType.REQUEST_CHANNEL, firstPayload).flatMapMany((context) -> innerFlux
|
||||
.skip(1).flatMap((p) -> intercept(PayloadExchangeType.PAYLOAD, p).thenReturn(p))
|
||||
.transform((securedPayloads) -> Flux.concat(Flux.just(firstPayload), securedPayloads))
|
||||
.transform((securedPayloads) -> this.source.requestChannel(securedPayloads))
|
||||
.subscriberContext(context));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> metadataPush(Payload payload) {
|
||||
return intercept(PayloadExchangeType.METADATA_PUSH, payload)
|
||||
.flatMap(c -> this.source.metadataPush(payload).subscriberContext(c));
|
||||
.flatMap((c) -> this.source.metadataPush(payload).subscriberContext(c));
|
||||
}
|
||||
|
||||
private Mono<Context> intercept(PayloadExchangeType type, Payload payload) {
|
||||
|
||||
+2
-2
@@ -73,8 +73,8 @@ class PayloadSocketAcceptor implements SocketAcceptor {
|
||||
// FIXME do we want to make the sendingSocket available in the PayloadExchange
|
||||
return intercept(setup, dataMimeType, metadataMimeType)
|
||||
.flatMap(
|
||||
ctx -> this.delegate.accept(setup, sendingSocket)
|
||||
.map(acceptingSocket -> new PayloadInterceptorRSocket(acceptingSocket,
|
||||
(ctx) -> this.delegate.accept(setup, sendingSocket)
|
||||
.map((acceptingSocket) -> new PayloadInterceptorRSocket(acceptingSocket,
|
||||
this.interceptors, metadataMimeType, dataMimeType, ctx))
|
||||
.subscriberContext(ctx));
|
||||
}
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ public class BasicAuthenticationDecoder extends AbstractDecoder<UsernamePassword
|
||||
@Override
|
||||
public Flux<UsernamePasswordMetadata> decode(Publisher<DataBuffer> input, ResolvableType elementType,
|
||||
MimeType mimeType, Map<String, Object> hints) {
|
||||
return Flux.from(input).map(DataBuffer::asByteBuffer).map(byteBuffer -> {
|
||||
return Flux.from(input).map(DataBuffer::asByteBuffer).map((byteBuffer) -> {
|
||||
byte[] sizeBytes = new byte[4];
|
||||
byteBuffer.get(sizeBytes);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class BasicAuthenticationDecoder extends AbstractDecoder<UsernamePassword
|
||||
@Override
|
||||
public Mono<UsernamePasswordMetadata> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementType,
|
||||
MimeType mimeType, Map<String, Object> hints) {
|
||||
return Mono.from(input).map(DataBuffer::asByteBuffer).map(byteBuffer -> {
|
||||
return Mono.from(input).map(DataBuffer::asByteBuffer).map((byteBuffer) -> {
|
||||
int usernameSize = byteBuffer.getInt();
|
||||
byte[] usernameBytes = new byte[usernameSize];
|
||||
byteBuffer.get(usernameBytes);
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class BasicAuthenticationEncoder extends AbstractEncoder<UsernamePassword
|
||||
public Flux<DataBuffer> encode(Publisher<? extends UsernamePasswordMetadata> inputStream,
|
||||
DataBufferFactory bufferFactory, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
|
||||
return Flux.from(inputStream)
|
||||
.map(credentials -> encodeValue(credentials, bufferFactory, elementType, mimeType, hints));
|
||||
.map((credentials) -> encodeValue(credentials, bufferFactory, elementType, mimeType, hints));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class BearerTokenAuthenticationEncoder extends AbstractEncoder<BearerToke
|
||||
public Flux<DataBuffer> encode(Publisher<? extends BearerTokenMetadata> inputStream,
|
||||
DataBufferFactory bufferFactory, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
|
||||
return Flux.from(inputStream)
|
||||
.map(credentials -> encodeValue(credentials, bufferFactory, elementType, mimeType, hints));
|
||||
.map((credentials) -> encodeValue(credentials, bufferFactory, elementType, mimeType, hints));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class SimpleAuthenticationEncoder extends AbstractEncoder<UsernamePasswor
|
||||
public Flux<DataBuffer> encode(Publisher<? extends UsernamePasswordMetadata> inputStream,
|
||||
DataBufferFactory bufferFactory, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
|
||||
return Flux.from(inputStream)
|
||||
.map(credentials -> encodeValue(credentials, bufferFactory, elementType, mimeType, hints));
|
||||
.map((credentials) -> encodeValue(credentials, bufferFactory, elementType, mimeType, hints));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -53,8 +53,8 @@ public class RoutePayloadExchangeMatcher implements PayloadExchangeMatcher {
|
||||
Map<String, Object> metadata = this.metadataExtractor.extract(exchange.getPayload(),
|
||||
exchange.getMetadataMimeType());
|
||||
return Optional.ofNullable((String) metadata.get(MetadataExtractor.ROUTE_KEY))
|
||||
.map(routeValue -> this.routeMatcher.parseRoute(routeValue))
|
||||
.map(route -> this.routeMatcher.matchAndExtract(this.pattern, route)).map(v -> MatchResult.match(v))
|
||||
.map((routeValue) -> this.routeMatcher.parseRoute(routeValue))
|
||||
.map((route) -> this.routeMatcher.matchAndExtract(this.pattern, route)).map((v) -> MatchResult.match(v))
|
||||
.orElse(MatchResult.notMatch());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ class AuthenticationPayloadInterceptorChain implements PayloadInterceptorChain {
|
||||
@Override
|
||||
public Mono<Void> next(PayloadExchange exchange) {
|
||||
return ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication)
|
||||
.doOnNext(a -> this.setAuthentication(a)).then();
|
||||
.doOnNext((a) -> this.setAuthentication(a)).then();
|
||||
}
|
||||
|
||||
public Authentication getAuthentication() {
|
||||
|
||||
+4
-2
@@ -77,7 +77,8 @@ public class PayloadExchangeMatcherReactiveAuthorizationManagerTests {
|
||||
given(this.authz.check(any(), any())).willReturn(Mono.just(expected));
|
||||
PayloadExchangeMatcherReactiveAuthorizationManager manager = PayloadExchangeMatcherReactiveAuthorizationManager
|
||||
.builder().add(new PayloadExchangeMatcherEntry<>(PayloadExchangeMatchers.anyExchange(), this.authz))
|
||||
.add(new PayloadExchangeMatcherEntry<>(e -> PayloadExchangeMatcher.MatchResult.notMatch(), this.authz2))
|
||||
.add(new PayloadExchangeMatcherEntry<>((e) -> PayloadExchangeMatcher.MatchResult.notMatch(),
|
||||
this.authz2))
|
||||
.build();
|
||||
|
||||
assertThat(manager.check(Mono.empty(), this.exchange).block()).isEqualTo(expected);
|
||||
@@ -89,7 +90,8 @@ public class PayloadExchangeMatcherReactiveAuthorizationManagerTests {
|
||||
given(this.authz2.check(any(), any())).willReturn(Mono.just(expected));
|
||||
PayloadExchangeMatcherReactiveAuthorizationManager manager = PayloadExchangeMatcherReactiveAuthorizationManager
|
||||
.builder()
|
||||
.add(new PayloadExchangeMatcherEntry<>(e -> PayloadExchangeMatcher.MatchResult.notMatch(), this.authz))
|
||||
.add(new PayloadExchangeMatcherEntry<>((e) -> PayloadExchangeMatcher.MatchResult.notMatch(),
|
||||
this.authz))
|
||||
.add(new PayloadExchangeMatcherEntry<>(PayloadExchangeMatchers.anyExchange(), this.authz2)).build();
|
||||
|
||||
assertThat(manager.check(Mono.empty(), this.exchange).block()).isEqualTo(expected);
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ class CaptureSecurityContextSocketAcceptor implements SocketAcceptor {
|
||||
@Override
|
||||
public Mono<RSocket> accept(ConnectionSetupPayload setup, RSocket sendingSocket) {
|
||||
return ReactiveSecurityContextHolder.getContext()
|
||||
.doOnNext(securityContext -> this.securityContext = securityContext).thenReturn(this.accept);
|
||||
.doOnNext((securityContext) -> this.securityContext = securityContext).thenReturn(this.accept);
|
||||
}
|
||||
|
||||
public SecurityContext getSecurityContext() {
|
||||
|
||||
+12
-12
@@ -140,7 +140,7 @@ public class PayloadInterceptorRSocketTests {
|
||||
|
||||
StepVerifier.create(interceptor.fireAndForget(this.payload))
|
||||
.then(() -> this.voidResult.assertWasNotSubscribed())
|
||||
.verifyErrorSatisfies(e -> assertThat(e).isEqualTo(expected));
|
||||
.verifyErrorSatisfies((e) -> assertThat(e).isEqualTo(expected));
|
||||
|
||||
verify(this.interceptor).intercept(this.exchange.capture(), any());
|
||||
assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload);
|
||||
@@ -155,7 +155,7 @@ public class PayloadInterceptorRSocketTests {
|
||||
RSocket assertAuthentication = new RSocketProxy(this.delegate) {
|
||||
@Override
|
||||
public Mono<Void> fireAndForget(Payload payload) {
|
||||
return assertAuthentication(authentication).flatMap(a -> super.fireAndForget(payload));
|
||||
return assertAuthentication(authentication).flatMap((a) -> super.fireAndForget(payload));
|
||||
}
|
||||
};
|
||||
PayloadInterceptorRSocket interceptor = new PayloadInterceptorRSocket(assertAuthentication,
|
||||
@@ -209,7 +209,7 @@ public class PayloadInterceptorRSocketTests {
|
||||
RSocket assertAuthentication = new RSocketProxy(this.delegate) {
|
||||
@Override
|
||||
public Mono<Payload> requestResponse(Payload payload) {
|
||||
return assertAuthentication(authentication).flatMap(a -> super.requestResponse(payload));
|
||||
return assertAuthentication(authentication).flatMap((a) -> super.requestResponse(payload));
|
||||
}
|
||||
};
|
||||
PayloadInterceptorRSocket interceptor = new PayloadInterceptorRSocket(assertAuthentication,
|
||||
@@ -249,7 +249,7 @@ public class PayloadInterceptorRSocketTests {
|
||||
|
||||
StepVerifier.create(interceptor.requestStream(this.payload))
|
||||
.then(() -> this.payloadResult.assertNoSubscribers())
|
||||
.verifyErrorSatisfies(e -> assertThat(e).isEqualTo(expected));
|
||||
.verifyErrorSatisfies((e) -> assertThat(e).isEqualTo(expected));
|
||||
|
||||
verify(this.interceptor).intercept(this.exchange.capture(), any());
|
||||
assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload);
|
||||
@@ -264,7 +264,7 @@ public class PayloadInterceptorRSocketTests {
|
||||
RSocket assertAuthentication = new RSocketProxy(this.delegate) {
|
||||
@Override
|
||||
public Flux<Payload> requestStream(Payload payload) {
|
||||
return assertAuthentication(authentication).flatMapMany(a -> super.requestStream(payload));
|
||||
return assertAuthentication(authentication).flatMapMany((a) -> super.requestStream(payload));
|
||||
}
|
||||
};
|
||||
PayloadInterceptorRSocket interceptor = new PayloadInterceptorRSocket(assertAuthentication,
|
||||
@@ -305,7 +305,7 @@ public class PayloadInterceptorRSocketTests {
|
||||
|
||||
StepVerifier.create(interceptor.requestChannel(Flux.just(this.payload)))
|
||||
.then(() -> this.payloadResult.assertNoSubscribers())
|
||||
.verifyErrorSatisfies(e -> assertThat(e).isEqualTo(expected));
|
||||
.verifyErrorSatisfies((e) -> assertThat(e).isEqualTo(expected));
|
||||
|
||||
verify(this.interceptor).intercept(this.exchange.capture(), any());
|
||||
assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload);
|
||||
@@ -321,7 +321,7 @@ public class PayloadInterceptorRSocketTests {
|
||||
RSocket assertAuthentication = new RSocketProxy(this.delegate) {
|
||||
@Override
|
||||
public Flux<Payload> requestChannel(Publisher<Payload> payload) {
|
||||
return assertAuthentication(authentication).flatMapMany(a -> super.requestChannel(payload));
|
||||
return assertAuthentication(authentication).flatMapMany((a) -> super.requestChannel(payload));
|
||||
}
|
||||
};
|
||||
PayloadInterceptorRSocket interceptor = new PayloadInterceptorRSocket(assertAuthentication,
|
||||
@@ -359,7 +359,7 @@ public class PayloadInterceptorRSocketTests {
|
||||
Arrays.asList(this.interceptor), this.metadataMimeType, this.dataMimeType);
|
||||
|
||||
StepVerifier.create(interceptor.metadataPush(this.payload)).then(() -> this.voidResult.assertWasNotSubscribed())
|
||||
.verifyErrorSatisfies(e -> assertThat(e).isEqualTo(expected));
|
||||
.verifyErrorSatisfies((e) -> assertThat(e).isEqualTo(expected));
|
||||
|
||||
verify(this.interceptor).intercept(this.exchange.capture(), any());
|
||||
assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload);
|
||||
@@ -374,7 +374,7 @@ public class PayloadInterceptorRSocketTests {
|
||||
RSocket assertAuthentication = new RSocketProxy(this.delegate) {
|
||||
@Override
|
||||
public Mono<Void> metadataPush(Payload payload) {
|
||||
return assertAuthentication(authentication).flatMap(a -> super.metadataPush(payload));
|
||||
return assertAuthentication(authentication).flatMap((a) -> super.metadataPush(payload));
|
||||
}
|
||||
};
|
||||
PayloadInterceptorRSocket interceptor = new PayloadInterceptorRSocket(assertAuthentication,
|
||||
@@ -459,11 +459,11 @@ public class PayloadInterceptorRSocketTests {
|
||||
|
||||
private Mono<Authentication> assertAuthentication(Authentication authentication) {
|
||||
return ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication)
|
||||
.doOnNext(a -> assertThat(a).isEqualTo(authentication));
|
||||
.doOnNext((a) -> assertThat(a).isEqualTo(authentication));
|
||||
}
|
||||
|
||||
private Answer<Object> withAuthenticated(Authentication authentication) {
|
||||
return invocation -> {
|
||||
return (invocation) -> {
|
||||
PayloadInterceptorChain c = (PayloadInterceptorChain) invocation.getArguments()[1];
|
||||
return c.next(new DefaultPayloadExchange(PayloadExchangeType.REQUEST_CHANNEL, this.payload,
|
||||
this.metadataMimeType, this.dataMimeType))
|
||||
@@ -472,7 +472,7 @@ public class PayloadInterceptorRSocketTests {
|
||||
}
|
||||
|
||||
private static Answer<Mono<Void>> withChainNext() {
|
||||
return invocation -> {
|
||||
return (invocation) -> {
|
||||
PayloadExchange exchange = (PayloadExchange) invocation.getArguments()[0];
|
||||
PayloadInterceptorChain chain = (PayloadInterceptorChain) invocation.getArguments()[1];
|
||||
return chain.next(exchange);
|
||||
|
||||
Reference in New Issue
Block a user