diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java index 30ab1870..fd6e8ca5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java @@ -99,7 +99,8 @@ public ArrayList getSuperClasses(String type) { @Override public void close() throws IOException { - cp.stream().forEach(IOHelper::close); + cp.stream().forEach(IOHelper::close); + cp.clear(); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/StripLineNumbersTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/StripLineNumbersTask.java index f6b9be68..d8baa571 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/StripLineNumbersTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/StripLineNumbersTask.java @@ -17,13 +17,10 @@ import ru.gravit.utils.helper.IOHelper; public class StripLineNumbersTask implements LauncherBuildTask { - private final LaunchServer server; - private final ClassMetadataReader reader; public StripLineNumbersTask(LaunchServer server) { this.server = server; - reader = new ClassMetadataReader(); } @Override @@ -34,26 +31,27 @@ public String getName() { @Override public Path process(Path inputFile) throws IOException { Path out = server.dir.resolve(server.config.projectName + "-stripped.jar"); - reader.getCp().add(new JarFile(inputFile.toFile())); - try (ZipInputStream input = IOHelper.newZipInput(inputFile); - ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(out))) { - ZipEntry e = input.getNextEntry(); - while (e != null) { - String filename = e.getName(); - output.putNextEntry(IOHelper.newZipEntry(e)); - if (filename.endsWith(".class")) { - byte[] bytes = null; - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) { - IOHelper.transfer(input, outputStream); - bytes = outputStream.toByteArray(); - } - output.write(classFix(bytes, reader)); - } else - IOHelper.transfer(input, output); - e = input.getNextEntry(); - } - } - reader.close(); + try (ClassMetadataReader reader = new ClassMetadataReader()) { + reader.getCp().add(new JarFile(inputFile.toFile())); + try (ZipInputStream input = IOHelper.newZipInput(inputFile); + ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(out))) { + ZipEntry e = input.getNextEntry(); + while (e != null) { + String filename = e.getName(); + output.putNextEntry(IOHelper.newZipEntry(e)); + if (filename.endsWith(".class")) { + byte[] bytes = null; + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) { + IOHelper.transfer(input, outputStream); + bytes = outputStream.toByteArray(); + } + output.write(classFix(bytes, reader)); + } else + IOHelper.transfer(input, output); + e = input.getNextEntry(); + } + } + } return out; }