Skip to content

Commit

Permalink
[1.20.1] Backport some fixes from main (#102)
Browse files Browse the repository at this point in the history
* Suppress error message in AbstractJarFileDependencyLocator if NSFE is thrown

* Only log errors when scanning mod file contents
  • Loading branch information
embeddedt authored Mar 24, 2024
1 parent 3adccc1 commit 21267b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.Optional;

Expand All @@ -25,8 +26,8 @@ protected Optional<InputStream> loadResourceFromModFile(final IModFile modFile,
try {
return Optional.of(Files.newInputStream(modFile.findResource(path.toString())));
}
catch (final FileNotFoundException e) {
LOGGER.debug("Failed to load resource {} from {}, it does not contain dependency information.", path, modFile.getFileName());
catch (final FileNotFoundException | NoSuchFileException e) {
LOGGER.trace("Failed to load resource {} from {}, it does not contain dependency information.", path, modFile.getFileName());
return Optional.empty();
}
catch (final Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ public ModFileScanData scan() {
}

private void fileVisitor(final Path path, final ModFileScanData result) {
LOGGER.debug(LogMarkers.SCAN,"Scanning {} path {}", fileToScan, path);
try (InputStream in = Files.newInputStream(path)){
ModClassVisitor mcv = new ModClassVisitor();
ClassReader cr = new ClassReader(in);
cr.accept(mcv, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG);
mcv.buildData(result.getClasses(), result.getAnnotations());
} catch (IOException | IllegalArgumentException e) {
// mark path bad
LOGGER.error(LogMarkers.SCAN,"Exception scanning {} path {}", fileToScan, path, e);
}
}
}

0 comments on commit 21267b8

Please sign in to comment.