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

UnsupportedOperationException due to toPath() call on PipePath #3

Closed
sciwhiz12 opened this issue Feb 3, 2021 · 0 comments
Closed

Comments

@sciwhiz12
Copy link

Logfile: https://gist.github.com/Bricktricker/67bbcf61eafe403d240060dfe798874d (from orig. reporter on The Forge Project discord)

if (outputPath.isFile()) {
Path out = outputPath.toPath();

The given lines are the root of the issue here: when OutputPath#isFile() is true, OutputPath#toPath() is called to convert the path into a Path object.
However, this causes an issue when the outputPath variable holds a PipePath: PipePath returns true for #isFile() but throws an UnsupportedOperationException for #toPath() (presumably because you cannot obtain a Path object for pipes). This causes the aforementioned crash via UnsupportedOperationException.

Although there is an if-check present before those lines, which short-circuits when the outputPath is a Pipe, this only returns and stops when the PipePath does not have a ArchiveFormat. If the PipePath does contain an ArchiveFormat, then this if-check passes and it goes straight into the aforementioned currently-crashing code.

if (outputPath.getType().isPipe() && outputPath.getFormat() == null) {
log("Err: Output detected as pipe but no format is specified.");
printHelp();
return new Result<>(-1);
}

The bug was reported via a user using ForgeGradle 4.0.14 and 4.0.15 (with 4.0.14 being the version of ForgeGradle that first switched to DiffPatch). The offending code which causes the issue is this, where a ByteArrayOutputStream with an archive format of ArchiveFormat.ZIP is given as the output path of the PatchOperation
https://github.com/MinecraftForge/ForgeGradle/blob/a74f4b155d3c41f495e4e03398ead9a95ef831f8/src/userdev/java/net/minecraftforge/gradle/userdev/MinecraftUserRepo.java#L1033-L1044

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

1 participant