Skip to content

Commit 46677e3

Browse files
wonwoophilwebb
authored andcommitted
Replace anonymous class with lambdas
See gh-17040
1 parent 0fcc561 commit 46677e3

File tree

2 files changed

+16
-46
lines changed

2 files changed

+16
-46
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -538,25 +538,20 @@ public void nonExistentUploadDirectoryIsCreatedUponMultipartUpload()
538538
throws IOException, URISyntaxException {
539539
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
540540
AtomicReference<ServletContext> servletContextReference = new AtomicReference<>();
541-
factory.addInitializers(new ServletContextInitializer() {
542-
543-
@Override
544-
public void onStartup(ServletContext servletContext) throws ServletException {
545-
servletContextReference.set(servletContext);
546-
Dynamic servlet = servletContext.addServlet("upload", new HttpServlet() {
547-
548-
@Override
549-
protected void doPost(HttpServletRequest req,
550-
HttpServletResponse resp)
551-
throws ServletException, IOException {
552-
req.getParts();
553-
}
554-
555-
});
556-
servlet.addMapping("/upload");
557-
servlet.setMultipartConfig(new MultipartConfigElement((String) null));
558-
}
541+
factory.addInitializers((ServletContextInitializer) servletContext -> {
542+
servletContextReference.set(servletContext);
543+
Dynamic servlet = servletContext.addServlet("upload", new HttpServlet() {
544+
545+
@Override
546+
protected void doPost(HttpServletRequest req,
547+
HttpServletResponse resp)
548+
throws ServletException, IOException {
549+
req.getParts();
550+
}
559551

552+
});
553+
servlet.addMapping("/upload");
554+
servlet.setMultipartConfig(new MultipartConfigElement((String) null));
560555
});
561556
this.webServer = factory.getWebServer();
562557
this.webServer.start();

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -503,16 +503,7 @@ public void pkcs12KeyStoreAndTrustStore() throws Exception {
503503
new SSLContextBuilder()
504504
.loadTrustMaterial(null, new TrustSelfSignedStrategy())
505505
.loadKeyMaterial(keyStore, "secret".toCharArray(),
506-
new PrivateKeyStrategy() {
507-
508-
@Override
509-
public String chooseAlias(
510-
Map<String, PrivateKeyDetails> aliases,
511-
Socket socket) {
512-
return "spring-boot";
513-
}
514-
515-
})
506+
(aliases, socket) -> "spring-boot")
516507
.build());
517508
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
518509
.build();
@@ -538,15 +529,7 @@ public void sslNeedsClientAuthenticationSucceedsWithClientCertificate()
538529
new SSLContextBuilder()
539530
.loadTrustMaterial(null, new TrustSelfSignedStrategy())
540531
.loadKeyMaterial(keyStore, "password".toCharArray(),
541-
new PrivateKeyStrategy() {
542-
543-
@Override
544-
public String chooseAlias(
545-
Map<String, PrivateKeyDetails> aliases,
546-
Socket socket) {
547-
return "spring-boot";
548-
}
549-
})
532+
(aliases, socket) -> "spring-boot")
550533
.build());
551534
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
552535
.build();
@@ -639,15 +622,7 @@ public void sslWithCustomSslStoreProvider() throws Exception {
639622
new SSLContextBuilder()
640623
.loadTrustMaterial(null, new TrustSelfSignedStrategy())
641624
.loadKeyMaterial(keyStore, "password".toCharArray(),
642-
new PrivateKeyStrategy() {
643-
644-
@Override
645-
public String chooseAlias(
646-
Map<String, PrivateKeyDetails> aliases,
647-
Socket socket) {
648-
return "spring-boot";
649-
}
650-
})
625+
(aliases, socket) -> "spring-boot")
651626
.build());
652627
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
653628
.build();

0 commit comments

Comments
 (0)