Skip to content

Commit

Permalink
Use parenthesis with single-arg lambdas
Browse files Browse the repository at this point in the history
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 spring-projectsgh-8945
  • Loading branch information
philwebb authored and rwinch committed Aug 24, 2020
1 parent 01d90c9 commit 52f20b5
Show file tree
Hide file tree
Showing 426 changed files with 1,669 additions and 1,618 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private void lookupPrimaryKeys(final Map<Serializable, Acl> acls, final Set<Long

String sql = computeRepeatingSql(this.lookupPrimaryKeysWhereClause, findNow.size());

Set<Long> parentsToLookup = this.jdbcTemplate.query(sql, ps -> {
Set<Long> parentsToLookup = this.jdbcTemplate.query(sql, (ps) -> {
int i = 0;

for (Long toFind : findNow) {
Expand Down Expand Up @@ -358,7 +358,7 @@ private Map<ObjectIdentity, Acl> lookupObjectIdentities(final Collection<ObjectI
// (including markers to each parent in the hierarchy)
String sql = computeRepeatingSql(this.lookupObjectIdentitiesWhereClause, objectIdentities.size());

Set<Long> parentsToLookup = this.jdbcTemplate.query(sql, ps -> {
Set<Long> parentsToLookup = this.jdbcTemplate.query(sql, (ps) -> {
int i = 0;
for (ObjectIdentity oid : objectIdentities) {
// Determine prepared statement values for this iteration
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/lock/GlobalLockPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class GlobalLockPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
project.getTasks().register("writeLocks", GlobalLockTask.class, writeAll -> {
project.getTasks().register("writeLocks", GlobalLockTask.class, (writeAll) -> {
writeAll.setDescription("Writes the locks for all projects");
});
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/trang/TrangPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class TrangPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
project.getTasks().register("rncToXsd", RncToXsd.class, rncToXsd -> {
project.getTasks().register("rncToXsd", RncToXsd.class, (rncToXsd) -> {
rncToXsd.setDescription("Converts .rnc to .xsd");
rncToXsd.setGroup("Build");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testNormalOperation() throws Exception {
request.addParameter("ticket", "ST-0-ER94xMJmn6pha35CQRoZ");

CasAuthenticationFilter filter = new CasAuthenticationFilter();
filter.setAuthenticationManager(a -> a);
filter.setAuthenticationManager((a) -> a);

assertThat(filter.requiresAuthentication(request, new MockHttpServletResponse())).isTrue();

Expand All @@ -82,7 +82,7 @@ public void testNormalOperation() throws Exception {
@Test(expected = AuthenticationException.class)
public void testNullServiceTicketHandledGracefully() throws Exception {
CasAuthenticationFilter filter = new CasAuthenticationFilter();
filter.setAuthenticationManager(a -> {
filter.setAuthenticationManager((a) -> {
throw new BadCredentialsException("Rejected");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public RSocketStrategies rsocketStrategies() {

@Bean
PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) {
rsocket.authorizePayload(authorize -> authorize.anyRequest().authenticated().anyExchange().permitAll())
rsocket.authorizePayload((authorize) -> authorize.anyRequest().authenticated().anyExchange().permitAll())
.jwt(Customizer.withDefaults());
return rsocket.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ MapReactiveUserDetailsService uds() {

@Bean
PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) {
rsocket.authorizePayload(authorize -> authorize.setup().hasRole("SETUP").route("secure.admin.*")
rsocket.authorizePayload((authorize) -> authorize.setup().hasRole("SETUP").route("secure.admin.*")
.hasRole("ADMIN").route("secure.**").hasRole("USER").route("secure.authority.*")
.hasAuthority("ROLE_USER").route("management.*").hasAnyAuthority("ROLE_ADMIN").route("prohibit")
.denyAll().anyRequest().permitAll()).basicAuthentication(Customizer.withDefaults());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void setup() {
.transport(TcpServerTransport.create("localhost", 0)).start().block();

this.requester = RSocketRequester.builder()
// .rsocketFactory(factory ->
// .rsocketFactory((factory) ->
// factory.addRequesterPlugin(payloadInterceptor))
.rsocketStrategies(this.handler.getRSocketStrategies())
.connectTcp("localhost", this.server.address().getPort()).block();
Expand Down Expand Up @@ -221,7 +221,7 @@ MapReactiveUserDetailsService uds() {

@Bean
PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) {
rsocket.authorizePayload(authorize -> {
rsocket.authorizePayload((authorize) -> {
authorize.route("secure.*").authenticated().anyExchange().permitAll();
}).basicAuthentication(Customizer.withDefaults());
return rsocket.build();
Expand All @@ -242,7 +242,7 @@ String retrieveMono(String payload) {

@MessageMapping({ "secure.retrieve-flux", "retrieve-flux" })
Flux<String> retrieveFlux(Flux<String> payload) {
return payload.doOnNext(this::add).map(p -> "hello " + p);
return payload.doOnNext(this::add).map((p) -> "hello " + p);
}

@MessageMapping({ "secure.send", "send" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public RSocketStrategies rsocketStrategies() {

@Bean
PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) {
rsocket.authorizePayload(authorize -> authorize.anyRequest().authenticated().anyExchange().permitAll())
rsocket.authorizePayload((authorize) -> authorize.anyRequest().authenticated().anyExchange().permitAll())
.simpleAuthentication(Customizer.withDefaults());
return rsocket.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public void inetOrgContextMapperIsSupported() {

ProviderManager providerManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER, ProviderManager.class);
assertThat(providerManager.getProviders()).hasSize(1);
assertThat(providerManager.getProviders()).extracting("userDetailsContextMapper")
.allSatisfy(contextMapper -> assertThat(contextMapper).isInstanceOf(InetOrgPersonContextMapper.class));
assertThat(providerManager.getProviders()).extracting("userDetailsContextMapper").allSatisfy(
(contextMapper) -> assertThat(contextMapper).isInstanceOf(InetOrgPersonContextMapper.class));
}

@Test
Expand All @@ -153,10 +153,10 @@ public void ldapAuthenticationProviderWorksWithPlaceholders() {

AuthenticationProvider authenticationProvider = providerManager.getProviders().get(0);
assertThat(authenticationProvider).extracting("authenticator.userDnFormat")
.satisfies(messageFormats -> assertThat(messageFormats)
.satisfies((messageFormats) -> assertThat(messageFormats)
.isEqualTo(new MessageFormat[] { new MessageFormat("uid={0},ou=people") }));
assertThat(authenticationProvider).extracting("authoritiesPopulator.groupSearchFilter")
.satisfies(searchFilter -> assertThat(searchFilter).isEqualTo("member={0}"));
.satisfies((searchFilter) -> assertThat(searchFilter).isEqualTo("member={0}"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface Customizer<T> {
* @return a {@link Customizer} that does not alter the input argument.
*/
static <T> Customizer<T> withDefaults() {
return t -> {
return (t) -> {
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* &#064;Bean
* PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) {
* rsocket
* .authorizePayload(authorize ->
* .authorizePayload((authorize) ->
* authorize
* .anyRequest().authenticated()
* );
Expand All @@ -87,7 +87,7 @@
* &#064;Bean
* PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) {
* rsocket
* .authorizePayload(authorize ->
* .authorizePayload((authorize) ->
* authorize
* // must have ROLE_SETUP to make connection
* .setup().hasRole("SETUP")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ private PayloadSocketAcceptorInterceptor defaultInterceptor(ObjectProvider<RSock
throw new NoSuchBeanDefinitionException("No RSocketSecurity defined");
}
rsocket.basicAuthentication(Customizer.withDefaults()).simpleAuthentication(Customizer.withDefaults())
.authorizePayload(authz -> authz.setup().authenticated().anyRequest().authenticated()
.matcher(e -> MatchResult.match()).permitAll());
.authorizePayload((authz) -> authz.setup().authenticated().anyRequest().authenticated()
.matcher((e) -> MatchResult.match()).permitAll());
return rsocket.build();
}

Expand Down
Loading

0 comments on commit 52f20b5

Please sign in to comment.