Commit 0db6799d authored by Phillip Webb's avatar Phillip Webb

Polish spring-boot-loader-tools

Issue: #53129653
parent 826f4274
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package org.springframework.boot.loader.tools; package org.springframework.boot.loader.tools;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -25,6 +26,7 @@ import java.io.FilterInputStream; ...@@ -25,6 +26,7 @@ import java.io.FilterInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashSet; import java.util.HashSet;
...@@ -45,7 +47,7 @@ import java.util.zip.ZipEntry; ...@@ -45,7 +47,7 @@ import java.util.zip.ZipEntry;
*/ */
class JarWriter { class JarWriter {
private static final String NESTED_LOADER_JAR = "/META-INF/loader/spring-boot-loader.jar"; private static final String NESTED_LOADER_JAR = "META-INF/loader/spring-boot-loader.jar";
private static final int BUFFER_SIZE = 4096; private static final int BUFFER_SIZE = 4096;
...@@ -122,8 +124,9 @@ class JarWriter { ...@@ -122,8 +124,9 @@ class JarWriter {
* @throws IOException * @throws IOException
*/ */
public void writeLoaderClasses() throws IOException { public void writeLoaderClasses() throws IOException {
JarInputStream inputStream = new JarInputStream(getClass().getResourceAsStream( URL loaderJar = getClass().getClassLoader().getResource(NESTED_LOADER_JAR);
NESTED_LOADER_JAR)); JarInputStream inputStream = new JarInputStream(new BufferedInputStream(
loaderJar.openStream()));
JarEntry entry; JarEntry entry;
while ((entry = inputStream.getNextJarEntry()) != null) { while ((entry = inputStream.getNextJarEntry()) != null) {
if (entry.getName().endsWith(".class")) { if (entry.getName().endsWith(".class")) {
......
...@@ -51,7 +51,7 @@ public class Repackager { ...@@ -51,7 +51,7 @@ public class Repackager {
/** /**
* Sets the main class that should be run. If not specified the value from the * Sets the main class that should be run. If not specified the value from the
* MANIFEST will be used, or if no manifest entry is found a class the archive will be * MANIFEST will be used, or if no manifest entry is found the archive will be
* searched for a suitable class. * searched for a suitable class.
* @param mainClass the main class name * @param mainClass the main class name
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment