From 4d0da4b700c08bead46084da33d77131587ab60f Mon Sep 17 00:00:00 2001 From: Yuyan <845058547@qq.com> Date: Thu, 26 Sep 2019 19:09:28 -0700 Subject: [PATCH] Simplify code See gh-18342 --- .../boot/gradle/tasks/bundling/BootArchiveSupport.java | 4 ++-- .../tomcat/TomcatServletWebServerFactoryTests.java | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java index 48b42b10a6..bf6a818d34 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java @@ -143,8 +143,8 @@ class BootArchiveSupport { } private boolean isZip(InputStream inputStream) throws IOException { - for (int i = 0; i < ZIP_FILE_HEADER.length; i++) { - if (inputStream.read() != ZIP_FILE_HEADER[i]) { + for (byte b : ZIP_FILE_HEADER) { + if (inputStream.read() != b) { return false; } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java index 941120ff5f..2c138b96de 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java @@ -544,14 +544,7 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory @Test void registerJspServletWithDefaultLoadOnStartup() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0); - factory.addInitializers(new ServletContextInitializer() { - - @Override - public void onStartup(ServletContext servletContext) throws ServletException { - servletContext.addServlet("manually-registered-jsp-servlet", JspServlet.class); - } - - }); + factory.addInitializers(servletContext -> servletContext.addServlet("manually-registered-jsp-servlet", JspServlet.class)); this.webServer = factory.getWebServer(); this.webServer.start(); }