Fix leaking unclosed InputStream in Scanner.fileVisitor (#5432)

This commit is contained in:
Bartosz Skrzypczak 2019-02-07 07:57:00 +01:00 committed by LexManos
parent 0b1b3c68fa
commit b527bf8ab3

View file

@ -26,6 +26,7 @@ import org.apache.logging.log4j.Logger;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@ -50,10 +51,10 @@ public class Scanner {
} }
private void fileVisitor(final Path path, final ModFileScanData result) { private void fileVisitor(final Path path, final ModFileScanData result) {
try { LOGGER.debug(SCAN,"Scanning {} path {}", fileToScan, path);
LOGGER.debug(SCAN,"Scanning {} path {}", fileToScan, path); try (InputStream in = Files.newInputStream(path)){
ModClassVisitor mcv = new ModClassVisitor(); ModClassVisitor mcv = new ModClassVisitor();
ClassReader cr = new ClassReader(Files.newInputStream(path)); ClassReader cr = new ClassReader(in);
cr.accept(mcv, 0); cr.accept(mcv, 0);
mcv.buildData(result.getClasses(), result.getAnnotations()); mcv.buildData(result.getClasses(), result.getAnnotations());
} catch (IOException e) { } catch (IOException e) {