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:
Phillip Webb
2020-07-29 18:18:05 -07:00
committed by Rob Winch
parent 01d90c9881
commit 52f20b5281
426 changed files with 1668 additions and 1617 deletions

View File

@@ -142,10 +142,10 @@ public class MockWebServerPropertySource extends PropertySource<MockWebServer> i
private MockResponse doDispatch(RecordedRequest request) {
if ("/introspect".equals(request.getPath())) {
return Optional.ofNullable(request.getHeader(HttpHeaders.AUTHORIZATION))
.filter(authorization -> isAuthorized(authorization, "client", "secret"))
.map(authorization -> parseBody(request.getBody()))
.map(parameters -> parameters.get("token"))
.map(token -> {
.filter((authorization) -> isAuthorized(authorization, "client", "secret"))
.map((authorization) -> parseBody(request.getBody()))
.map((parameters) -> parameters.get("token"))
.map((token) -> {
if ("00ed5855-1869-47a0-b0c9-0f3ce520aee7".equals(token)) {
return NO_SCOPES_RESPONSE;
} else if ("b43d1500-c405-4dc9-b9c9-6cfd966c34c9".equals(token)) {
@@ -167,8 +167,8 @@ public class MockWebServerPropertySource extends PropertySource<MockWebServer> i
private Map<String, Object> parseBody(Buffer body) {
return Stream.of(body.readUtf8().split("&"))
.map(parameter -> parameter.split("="))
.collect(Collectors.toMap(parts -> parts[0], parts -> parts[1]));
.map((parameter) -> parameter.split("="))
.collect(Collectors.toMap((parts) -> parts[0], (parts) -> parts[1]));
}
private static MockResponse response(String body, int status) {

View File

@@ -36,15 +36,15 @@ public class OAuth2ResourceServerSecurityConfiguration extends WebSecurityConfig
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests(authorizeRequests ->
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.antMatchers(HttpMethod.GET, "/message/**").hasAuthority("SCOPE_message:read")
.antMatchers(HttpMethod.POST, "/message/**").hasAuthority("SCOPE_message:write")
.anyRequest().authenticated()
)
.oauth2ResourceServer(oauth2ResourceServer ->
.oauth2ResourceServer((oauth2ResourceServer) ->
oauth2ResourceServer
.opaqueToken(opaqueToken ->
.opaqueToken((opaqueToken) ->
opaqueToken
.introspectionUri(this.introspectionUri)
.introspectionClientCredentials(this.clientId, this.clientSecret)

View File

@@ -46,13 +46,13 @@ public class OAuth2ResourceServerControllerTests {
@Test
public void indexGreetsAuthenticatedUser() throws Exception {
this.mvc.perform(get("/").with(opaqueToken().attributes(a -> a.put("sub", "ch4mpy"))))
this.mvc.perform(get("/").with(opaqueToken().attributes((a) -> a.put("sub", "ch4mpy"))))
.andExpect(content().string(is("Hello, ch4mpy!")));
}
@Test
public void messageCanBeReadWithScopeMessageReadAuthority() throws Exception {
this.mvc.perform(get("/message").with(opaqueToken().attributes(a -> a.put("scope", "message:read"))))
this.mvc.perform(get("/message").with(opaqueToken().attributes((a) -> a.put("scope", "message:read"))))
.andExpect(content().string(is("secret message")));
this.mvc.perform(get("/message")