Skip to content

Commit da6c7b8

Browse files
committed
Format Lambda Usage
This commit updates Lambda DSL usage to favor having the variable and reference on the same line Issue gh-13067
1 parent 777447e commit da6c7b8

35 files changed

+97
-194
lines changed

config/src/integration-test/java/org/springframework/security/config/annotation/rsocket/HelloRSocketITests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ public void setup() {
7474
// @formatter:off
7575
this.server = RSocketServer.create()
7676
.payloadDecoder(PayloadDecoder.ZERO_COPY)
77-
.interceptors((registry) ->
78-
registry.forSocketAcceptor(this.interceptor)
77+
.interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
7978
)
8079
.acceptor(this.handler.responder())
8180
.bind(TcpServerTransport.create("localhost", 0))

config/src/integration-test/java/org/springframework/security/config/annotation/rsocket/HelloRSocketObservationITests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ public void setup() {
8787
// @formatter:off
8888
this.server = RSocketServer.create()
8989
.payloadDecoder(PayloadDecoder.ZERO_COPY)
90-
.interceptors((registry) ->
91-
registry.forSocketAcceptor(this.interceptor)
90+
.interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
9291
)
9392
.acceptor(this.handler.responder())
9493
.bind(TcpServerTransport.create("localhost", 0))

config/src/integration-test/java/org/springframework/security/config/annotation/rsocket/HelloRSocketWithWebFluxITests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ public void setup() {
7474
// @formatter:off
7575
this.server = RSocketServer.create()
7676
.payloadDecoder(PayloadDecoder.ZERO_COPY)
77-
.interceptors((registry) ->
78-
registry.forSocketAcceptor(this.interceptor)
77+
.interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
7978
)
8079
.acceptor(this.handler.responder())
8180
.bind(TcpServerTransport.create("localhost", 0))

config/src/integration-test/java/org/springframework/security/config/annotation/rsocket/JwtITests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ public void setup() {
8686
// @formatter:off
8787
this.server = RSocketServer.create()
8888
.payloadDecoder(PayloadDecoder.ZERO_COPY)
89-
.interceptors((registry) ->
90-
registry.forSocketAcceptor(this.interceptor)
89+
.interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
9190
)
9291
.acceptor(this.handler.responder())
9392
.bind(TcpServerTransport.create("localhost", 0))

config/src/integration-test/java/org/springframework/security/config/annotation/rsocket/RSocketMessageHandlerConnectionITests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ public void setup() {
8181
// @formatter:off
8282
this.server = RSocketServer.create()
8383
.payloadDecoder(PayloadDecoder.ZERO_COPY)
84-
.interceptors((registry) ->
85-
registry.forSocketAcceptor(this.interceptor)
84+
.interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
8685
)
8786
.acceptor(this.handler.responder())
8887
.bind(TcpServerTransport.create("localhost", 0))

config/src/integration-test/java/org/springframework/security/config/annotation/rsocket/RSocketMessageHandlerITests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ public void setup() {
7979
// @formatter:off
8080
this.server = RSocketServer.create()
8181
.payloadDecoder(PayloadDecoder.ZERO_COPY)
82-
.interceptors((registry) ->
83-
registry.forSocketAcceptor(this.interceptor)
82+
.interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
8483
)
8584
.acceptor(this.handler.responder())
8685
.bind(TcpServerTransport.create("localhost", 0))

config/src/integration-test/java/org/springframework/security/config/annotation/rsocket/SimpleAuthenticationITests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ public void setup() {
7979
// @formatter:off
8080
this.server = RSocketServer.create()
8181
.payloadDecoder(PayloadDecoder.ZERO_COPY)
82-
.interceptors((registry) ->
83-
registry.forSocketAcceptor(this.interceptor)
82+
.interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
8483
)
8584
.acceptor(this.handler.responder())
8685
.bind(TcpServerTransport.create("localhost", 0))

config/src/test/java/org/springframework/security/config/annotation/web/configurers/AnonymousConfigurerTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ static class AnonymousPrincipalInLambdaConfig {
129129
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
130130
// @formatter:off
131131
http
132-
.anonymous((anonymous) ->
133-
anonymous
132+
.anonymous((anonymous) -> anonymous
134133
.principal("principal")
135134
);
136135
return http.build();

config/src/test/java/org/springframework/security/config/annotation/web/configurers/ChannelSecurityConfigurerTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ static class RequiresChannelInLambdaConfig {
186186
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
187187
// @formatter:off
188188
http
189-
.requiresChannel((requiresChannel) ->
190-
requiresChannel
189+
.requiresChannel((requiresChannel) -> requiresChannel
191190
.anyRequest().requiresSecure()
192191
);
193192
return http.build();

config/src/test/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerIgnoringRequestMatchersTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ static class IgnoringRequestInLambdaMatchers {
128128
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
129129
// @formatter:off
130130
http
131-
.csrf((csrf) ->
132-
csrf
131+
.csrf((csrf) -> csrf
133132
.requireCsrfProtectionMatcher(new AntPathRequestMatcher("/path"))
134133
.ignoringRequestMatchers(this.requestMatcher)
135134
);
@@ -169,8 +168,7 @@ static class IgnoringPathsAndMatchersInLambdaConfig {
169168
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
170169
// @formatter:off
171170
http
172-
.csrf((csrf) ->
173-
csrf
171+
.csrf((csrf) -> csrf
174172
.ignoringRequestMatchers(new AntPathRequestMatcher("/no-csrf"))
175173
.ignoringRequestMatchers(this.requestMatcher)
176174
);

config/src/test/java/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurerAccessDeniedHandlerTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
116116
.authorizeRequests((authorize) -> authorize
117117
.anyRequest().denyAll()
118118
)
119-
.exceptionHandling((exceptionHandling) ->
120-
exceptionHandling
119+
.exceptionHandling((exceptionHandling) -> exceptionHandling
121120
.defaultAccessDeniedHandlerFor(
122121
this.teapotDeniedHandler,
123122
new AntPathRequestMatcher("/hello/**")

config/src/test/java/org/springframework/security/config/annotation/web/configurers/FormLoginConfigurerTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
518518
.authorizeRequests((authorize) -> authorize
519519
.anyRequest().hasRole("USER")
520520
)
521-
.formLogin((formLogin) ->
522-
formLogin
521+
.formLogin((formLogin) -> formLogin
523522
.loginPage("/authenticate")
524523
.permitAll()
525524
)
@@ -573,15 +572,13 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
573572
.authorizeRequests((authorize) -> authorize
574573
.anyRequest().authenticated()
575574
)
576-
.formLogin((formLogin) ->
577-
formLogin
575+
.formLogin((formLogin) -> formLogin
578576
.loginProcessingUrl("/loginCheck")
579577
.loginPage("/login")
580578
.defaultSuccessUrl("/", true)
581579
.permitAll()
582580
)
583-
.logout((logout) ->
584-
logout
581+
.logout((logout) -> logout
585582
.logoutSuccessUrl("/login")
586583
.logoutUrl("/logout")
587584
.deleteCookies("JSESSIONID")

config/src/test/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurerTests.java

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,7 @@ static class ContentTypeOptionsInLambdaConfig {
630630
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
631631
// @formatter:off
632632
http
633-
.headers((headers) ->
634-
headers
633+
.headers((headers) -> headers
635634
.defaultsDisabled()
636635
.contentTypeOptions(withDefaults())
637636
);
@@ -700,8 +699,7 @@ static class CacheControlInLambdaConfig {
700699
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
701700
// @formatter:off
702701
http
703-
.headers((headers) ->
704-
headers
702+
.headers((headers) -> headers
705703
.defaultsDisabled()
706704
.cacheControl(withDefaults())
707705
);
@@ -753,8 +751,7 @@ static class XssProtectionInLambdaConfig {
753751
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
754752
// @formatter:off
755753
http
756-
.headers((headers) ->
757-
headers
754+
.headers((headers) -> headers
758755
.defaultsDisabled()
759756
.xssProtection(withDefaults())
760757
);
@@ -772,11 +769,9 @@ static class XssProtectionValueEnabledModeBlockInLambdaConfig {
772769
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
773770
// @formatter:off
774771
http
775-
.headers((headers) ->
776-
headers
772+
.headers((headers) -> headers
777773
.defaultsDisabled()
778-
.xssProtection((xXssConfig) ->
779-
xXssConfig.headerValue(XXssProtectionHeaderWriter.HeaderValue.ENABLED_MODE_BLOCK)
774+
.xssProtection((xXssConfig) -> xXssConfig.headerValue(XXssProtectionHeaderWriter.HeaderValue.ENABLED_MODE_BLOCK)
780775
)
781776
);
782777
// @formatter:on
@@ -808,8 +803,7 @@ static class HeadersCustomSameOriginInLambdaConfig {
808803
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
809804
// @formatter:off
810805
http
811-
.headers((headers) ->
812-
headers
806+
.headers((headers) -> headers
813807
.frameOptions((frameOptionsConfig) -> frameOptionsConfig.sameOrigin())
814808
);
815809
return http.build();
@@ -976,11 +970,9 @@ static class HpkpWithReportUriInLambdaConfig {
976970
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
977971
// @formatter:off
978972
http
979-
.headers((headers) ->
980-
headers
973+
.headers((headers) -> headers
981974
.defaultsDisabled()
982-
.httpPublicKeyPinning((hpkp) ->
983-
hpkp
975+
.httpPublicKeyPinning((hpkp) -> hpkp
984976
.addSha256Pins("d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=")
985977
.reportUri("https://example.net/pkp-report")
986978
)
@@ -1035,11 +1027,9 @@ static class ContentSecurityPolicyReportOnlyInLambdaConfig {
10351027
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
10361028
// @formatter:off
10371029
http
1038-
.headers((headers) ->
1039-
headers
1030+
.headers((headers) -> headers
10401031
.defaultsDisabled()
1041-
.contentSecurityPolicy((csp) ->
1042-
csp
1032+
.contentSecurityPolicy((csp) -> csp
10431033
.policyDirectives("default-src 'self'; script-src trustedscripts.example.com")
10441034
.reportOnly()
10451035
)
@@ -1075,11 +1065,9 @@ static class ContentSecurityPolicyInvalidInLambdaConfig {
10751065
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
10761066
// @formatter:off
10771067
http
1078-
.headers((headers) ->
1079-
headers
1068+
.headers((headers) -> headers
10801069
.defaultsDisabled()
1081-
.contentSecurityPolicy((csp) ->
1082-
csp.policyDirectives("")
1070+
.contentSecurityPolicy((csp) -> csp.policyDirectives("")
10831071
)
10841072
);
10851073
return http.build();
@@ -1096,8 +1084,7 @@ static class ContentSecurityPolicyNoDirectivesInLambdaConfig {
10961084
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
10971085
// @formatter:off
10981086
http
1099-
.headers((headers) ->
1100-
headers
1087+
.headers((headers) -> headers
11011088
.defaultsDisabled()
11021089
.contentSecurityPolicy(withDefaults())
11031090
);
@@ -1132,8 +1119,7 @@ static class ReferrerPolicyDefaultInLambdaConfig {
11321119
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
11331120
// @formatter:off
11341121
http
1135-
.headers((headers) ->
1136-
headers
1122+
.headers((headers) -> headers
11371123
.defaultsDisabled()
11381124
.referrerPolicy(Customizer.withDefaults())
11391125
);
@@ -1168,11 +1154,9 @@ static class ReferrerPolicyCustomInLambdaConfig {
11681154
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
11691155
// @formatter:off
11701156
http
1171-
.headers((headers) ->
1172-
headers
1157+
.headers((headers) -> headers
11731158
.defaultsDisabled()
1174-
.referrerPolicy((referrerPolicy) ->
1175-
referrerPolicy.policy(ReferrerPolicy.SAME_ORIGIN)
1159+
.referrerPolicy((referrerPolicy) -> referrerPolicy.policy(ReferrerPolicy.SAME_ORIGIN)
11761160
)
11771161
);
11781162
return http.build();
@@ -1308,8 +1292,7 @@ static class HstsWithPreloadInLambdaConfig {
13081292
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
13091293
// @formatter:off
13101294
http
1311-
.headers((headers) ->
1312-
headers
1295+
.headers((headers) -> headers
13131296
.defaultsDisabled()
13141297
.httpStrictTransportSecurity((hstsConfig) -> hstsConfig.preload(true))
13151298
);

config/src/test/java/org/springframework/security/config/annotation/web/configurers/HttpSecurityRequestMatchersTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ static class RequestMatchersMvcMatcherInLambdaConfig {
336336
SecurityFilterChain filterChain(HttpSecurity http, HandlerMappingIntrospector introspector) throws Exception {
337337
// @formatter:off
338338
http
339-
.securityMatchers((matchers) ->
340-
matchers
339+
.securityMatchers((secure) -> secure
341340
.requestMatchers(new MvcRequestMatcher(introspector, "/path"))
342341
)
343342
.httpBasic(withDefaults())
@@ -409,8 +408,7 @@ SecurityFilterChain filterChain(HttpSecurity http, HandlerMappingIntrospector in
409408
mvcMatcherBuilder.servletPath("/spring");
410409
// @formatter:off
411410
http
412-
.securityMatchers((matchers) ->
413-
matchers
411+
.securityMatchers((secure) -> secure
414412
.requestMatchers(mvcMatcherBuilder.pattern("/path"))
415413
.requestMatchers("/never-match")
416414
)

config/src/test/java/org/springframework/security/config/annotation/web/configurers/JeeConfigurerTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
212212
.authorizeRequests((authorize) -> authorize
213213
.anyRequest().hasRole("USER")
214214
)
215-
.jee((jee) ->
216-
jee
215+
.jee((jee) -> jee
217216
.mappableRoles("USER")
218217
);
219218
return http.build();
@@ -233,8 +232,7 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
233232
.authorizeRequests((authorize) -> authorize
234233
.anyRequest().hasRole("USER")
235234
)
236-
.jee((jee) ->
237-
jee
235+
.jee((jee) -> jee
238236
.mappableAuthorities("ROLE_USER")
239237
);
240238
return http.build();
@@ -257,8 +255,7 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
257255
.authorizeRequests((authorize) -> authorize
258256
.anyRequest().hasRole("USER")
259257
)
260-
.jee((jee) ->
261-
jee
258+
.jee((jee) -> jee
262259
.authenticatedUserDetailsService(authenticationUserDetailsService)
263260
);
264261
return http.build();

config/src/test/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurerTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,7 @@ static class NullLogoutSuccessHandlerInLambdaConfig {
431431
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
432432
// @formatter:off
433433
http
434-
.logout((logout) ->
435-
logout.defaultLogoutSuccessHandlerFor(null, mock(RequestMatcher.class))
434+
.logout((logout) -> logout.defaultLogoutSuccessHandlerFor(null, mock(RequestMatcher.class))
436435
);
437436
return http.build();
438437
// @formatter:on
@@ -464,8 +463,7 @@ static class NullMatcherInLambdaConfig {
464463
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
465464
// @formatter:off
466465
http
467-
.logout((logout) ->
468-
logout.defaultLogoutSuccessHandlerFor(mock(LogoutSuccessHandler.class), null)
466+
.logout((logout) -> logout.defaultLogoutSuccessHandlerFor(mock(LogoutSuccessHandler.class), null)
469467
);
470468
return http.build();
471469
// @formatter:on

config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpBasicTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,7 @@ static class AuthenticationDetailsSourceHttpBasicLambdaConfig {
280280
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
281281
// @formatter:off
282282
http
283-
.httpBasic((httpBasicConfig) ->
284-
httpBasicConfig.authenticationDetailsSource(this.authenticationDetailsSource));
283+
.httpBasic((httpBasicConfig) -> httpBasicConfig.authenticationDetailsSource(this.authenticationDetailsSource));
285284
return http.build();
286285
// @formatter:on
287286
}
@@ -326,8 +325,7 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
326325
.authorizeRequests((authorize) -> authorize
327326
.anyRequest().hasRole("USER")
328327
)
329-
.httpBasic((httpBasicConfig) ->
330-
httpBasicConfig.authenticationEntryPoint(this.authenticationEntryPoint));
328+
.httpBasic((httpBasicConfig) -> httpBasicConfig.authenticationEntryPoint(this.authenticationEntryPoint));
331329
return http.build();
332330
// @formatter:on
333331
}

config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpLogoutTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ static class CustomHttpLogoutInLambdaConfig {
215215
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
216216
// @formatter:off
217217
http
218-
.logout((logout) ->
219-
logout.deleteCookies("remove")
218+
.logout((logout) -> logout.deleteCookies("remove")
220219
.invalidateHttpSession(false)
221220
.logoutUrl("/custom-logout")
222221
.logoutSuccessUrl("/logout-success")

0 commit comments

Comments
 (0)