From 77a262c5425bc8d2269c3cd287c6f049a7c50ac4 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Mon, 29 Jul 2019 23:24:21 +0900 Subject: [PATCH] Polish See gh-17691 --- ...edServletContainerWarDevelopmentIntegrationTests.java | 9 ++------- ...ddedServletContainerWarPackagingIntegrationTests.java | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarDevelopmentIntegrationTests.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarDevelopmentIntegrationTests.java index 7a71f201b7a..98c4258c989 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarDevelopmentIntegrationTests.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarDevelopmentIntegrationTests.java @@ -19,10 +19,10 @@ package org.springframework.boot.context.embedded; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; import org.junit.Test; import org.junit.runner.RunWith; @@ -85,13 +85,8 @@ public class EmbeddedServletContainerWarDevelopmentIntegrationTests if (input == null) { return Collections.emptyList(); } - List lines = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new StringReader(input))) { - String line; - while ((line = reader.readLine()) != null) { - lines.add(line); - } - return lines; + return reader.lines().collect(Collectors.toList()); } catch (IOException ex) { throw new RuntimeException("Failed to read lines from input '" + input + "'"); diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarPackagingIntegrationTests.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarPackagingIntegrationTests.java index b1fff70aa07..69dc3703eed 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarPackagingIntegrationTests.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarPackagingIntegrationTests.java @@ -19,10 +19,10 @@ package org.springframework.boot.context.embedded; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; import org.junit.Test; import org.junit.runner.RunWith; @@ -108,13 +108,8 @@ public class EmbeddedServletContainerWarPackagingIntegrationTests if (input == null) { return Collections.emptyList(); } - List lines = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new StringReader(input))) { - String line; - while ((line = reader.readLine()) != null) { - lines.add(line); - } - return lines; + return reader.lines().collect(Collectors.toList()); } catch (IOException ex) { throw new RuntimeException("Failed to read lines from input '" + input + "'");