From 4979af9fa5c67a3325a519f27e54753f91d21899 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Sun, 29 Oct 2017 09:08:18 +0900 Subject: [PATCH] Remove unnecessary assignments Closes gh-10805 --- .../boot/configurationmetadata/JsonReader.java | 2 +- .../boot/loader/tools/DefaultLaunchScript.java | 2 +- .../java/org/springframework/boot/loader/tools/JarWriter.java | 4 ++-- .../org/springframework/boot/loader/tools/TestJarFile.java | 2 +- .../springframework/boot/loader/archive/JarFileArchive.java | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/JsonReader.java b/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/JsonReader.java index 732b3b9ba6..850ea012f7 100644 --- a/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/JsonReader.java +++ b/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/JsonReader.java @@ -209,7 +209,7 @@ class JsonReader { StringBuilder out = new StringBuilder(); InputStreamReader reader = new InputStreamReader(in, charset); char[] buffer = new char[BUFFER_SIZE]; - int bytesRead = -1; + int bytesRead; while ((bytesRead = reader.read(buffer)) != -1) { out.append(buffer, 0, bytesRead); } diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java index 3e917e54fe..552a85b01b 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java @@ -78,7 +78,7 @@ public class DefaultLaunchScript implements LaunchScript { private void copy(InputStream inputStream, OutputStream outputStream) throws IOException { byte[] buffer = new byte[BUFFER_SIZE]; - int bytesRead = -1; + int bytesRead; while ((bytesRead = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, bytesRead); } diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java index 948019e15f..a0e28c2ebf 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java @@ -300,7 +300,7 @@ public class JarWriter implements LoaderClassesWriter { @Override public void write(OutputStream outputStream) throws IOException { byte[] buffer = new byte[BUFFER_SIZE]; - int bytesRead = -1; + int bytesRead; while ((bytesRead = this.inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, bytesRead); } @@ -387,7 +387,7 @@ public class JarWriter implements LoaderClassesWriter { private void load(InputStream inputStream) throws IOException { byte[] buffer = new byte[BUFFER_SIZE]; - int bytesRead = -1; + int bytesRead; while ((bytesRead = inputStream.read(buffer)) != -1) { this.crc.update(buffer, 0, bytesRead); this.size += bytesRead; diff --git a/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java b/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java index 22d148d5e6..f118a08ff5 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java @@ -107,7 +107,7 @@ public class TestJarFile { } private void copy(InputStream in, OutputStream out) throws IOException { - int bytesRead = -1; + int bytesRead; while ((bytesRead = in.read(this.buffer)) != -1) { out.write(this.buffer, 0, bytesRead); } diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/JarFileArchive.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/JarFileArchive.java index a304503843..66eda986f8 100755 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/JarFileArchive.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/JarFileArchive.java @@ -150,7 +150,7 @@ public class JarFileArchive implements Archive { OutputStream outputStream = new FileOutputStream(file); try { byte[] buffer = new byte[BUFFER_SIZE]; - int bytesRead = -1; + int bytesRead; while ((bytesRead = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, bytesRead); }