Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/java/cpw/mods/jarhandling/impl/Jar.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ private List<Provider> gatherProviders(BiPredicate<String, String> filter) {
if (!Files.exists(services))
return List.of();

try {
return Files.list(services)
try (var servicesDirStream = Files.list(services)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this had issues with Zip file systems, calling close anywhere on them caused the entire thing to shut down.

return servicesDirStream
.filter(Files::isRegularFile)
.map(path -> getProvider(path, filter))
.toList();
Expand Down Expand Up @@ -324,8 +324,8 @@ private Map<String, String> gatherVersionedFiles() {

var ret = new HashMap<String, String>();
var versions = new HashMap<String, Integer>();
try {
Files.walk(versionsDir)
try (var versionsDirStream = Files.walk(versionsDir)) {
versionsDirStream
.filter(Files::isRegularFile)
.map(filesystemRoot::relativize)
.forEach(path -> {
Expand All @@ -344,8 +344,8 @@ private Map<String, String> gatherVersionedFiles() {

private Set<String> gatherPackages() {
var files = new HashSet<String>(this.nameOverrides.keySet());
try {
Files.walk(this.filesystemRoot)
try (var filesStream = Files.walk(this.filesystemRoot)) {
filesStream
.filter(p -> Files.isRegularFile(p) && !"META-INF".equals(p.getName(0).toString()))
.map(p -> this.filesystemRoot.relativize(p).toString().replace('\\', '/'))
.forEach(files::add);
Expand Down