Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple ListLibraries can run in parallel, corrupting each other #50

Closed
SquidDev opened this issue Nov 15, 2023 · 2 comments
Closed

Multiple ListLibraries can run in parallel, corrupting each other #50

SquidDev opened this issue Nov 15, 2023 · 2 comments

Comments

@SquidDev
Copy link
Contributor

I've a project which applies the userdev plugin in multiple sub-projects. However, attempting to build this project causes errors due to trying to use corrupted library jars.

> Task :forge:neoFormRename FAILED
Exception in thread "main" java.lang.RuntimeException: Could not add library: /home/squid/.gradle/caches/minecraft/libraries/org/apache/logging/log4j/log4j-core/2.19.0/log4j-core-2.19.0.jar
        at net.minecraftforge.fart.internal.ClassProviderBuilderImpl.addLibrary(ClassProviderBuilderImpl.java:56)
        at net.minecraftforge.fart.internal.RenamerImpl.lambda$setup$0(RenamerImpl.java:64)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at net.minecraftforge.fart.internal.RenamerImpl.setup(RenamerImpl.java:64)
        at net.minecraftforge.fart.internal.RenamerImpl.run(RenamerImpl.java:72)
        at net.minecraftforge.fart.Main.main(Main.java:159)
Caused by: java.util.zip.ZipException: zip END header not found
        at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.findEND(ZipFileSystem.java:1320)
        at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.initCEN(ZipFileSystem.java:1534)
        at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:179)
        at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getZipFileSystem(ZipFileSystemProvider.java:125)
        at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:120)
        at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:528)
        at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:400)
        at net.minecraftforge.fart.internal.ClassProviderBuilderImpl.addLibrary(ClassProviderBuilderImpl.java:38)
        ... 5 more

From what I can tell, the neoFormListLibraries task from one project runs in parallel with neoFormRename in another, causing the latter to read corrupt partially-downloaded jars.

I think there's several things which should be done to avoid this:

  • Download the files to a temporary location, and then move them to the directory once downloading has finished, to avoid partial downloads.
  • Only download the file if it is missing and the checksum is mismatched.

I'm happy to put a PR together for this if that would be useful?

@marchermans
Copy link
Contributor

marchermans commented Nov 16, 2023

There is a service that needs to be injected into the tasks or basically anything that uses the libraries.

Which brings up another complicated problem: decompile also uses that list and could run in parallel with lid libraries. We really need to get rid of the generic execute.

@SquidDev
Copy link
Contributor Author

This is fixed by #53.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants