diff --git a/changelog/@unreleased/pr-793.v2.yml b/changelog/@unreleased/pr-793.v2.yml new file mode 100644 index 000000000..0ebd74e08 --- /dev/null +++ b/changelog/@unreleased/pr-793.v2.yml @@ -0,0 +1,6 @@ +type: fix +fix: + description: Revert a performance optimization for large builds that sometimes resulted + in hangs due to infinite loops in TreeMap#get. + links: + - https://github.com/palantir/gradle-conjure/pull/793 diff --git a/gradle-conjure/src/main/java/com/palantir/gradle/conjure/ConjureRunnerResource.java b/gradle-conjure/src/main/java/com/palantir/gradle/conjure/ConjureRunnerResource.java index 4f83ec51f..ff27c6030 100644 --- a/gradle-conjure/src/main/java/com/palantir/gradle/conjure/ConjureRunnerResource.java +++ b/gradle-conjure/src/main/java/com/palantir/gradle/conjure/ConjureRunnerResource.java @@ -75,7 +75,7 @@ interface ConjureRunner extends Closeable { void invoke(Project project, String failedTo, List unloggedArgs, List loggedArgs); } - private static ConjureRunner createNewRunner(File executable) throws IOException { + static ConjureRunner createNewRunner(File executable) throws IOException { Optional maybeJava = ReverseEngineerJavaStartScript.maybeParseStartScript(executable.toPath()); if (maybeJava.isPresent()) { ReverseEngineerJavaStartScript.StartScriptInfo info = maybeJava.get(); diff --git a/gradle-conjure/src/main/java/com/palantir/gradle/conjure/GradleExecUtils.java b/gradle-conjure/src/main/java/com/palantir/gradle/conjure/GradleExecUtils.java index 6475a2f32..828bc9a16 100644 --- a/gradle-conjure/src/main/java/com/palantir/gradle/conjure/GradleExecUtils.java +++ b/gradle-conjure/src/main/java/com/palantir/gradle/conjure/GradleExecUtils.java @@ -16,32 +16,20 @@ package com.palantir.gradle.conjure; -import com.palantir.gradle.conjure.ConjureRunnerResource.Params; import java.io.File; +import java.io.IOException; import java.util.List; -import org.gradle.api.Action; import org.gradle.api.Project; -import org.gradle.api.services.BuildServiceSpec; final class GradleExecUtils { static void exec( Project project, String failedTo, File executable, List unloggedArgs, List loggedArgs) { - project.getGradle() - .getSharedServices() - .registerIfAbsent( - // Executable name must be the cache key, neither the spec parameters - // nor the class are taken into account for caching. - "conjure-runner-" + executable, - ConjureRunnerResource.class, - new Action>() { - @Override - public void execute(BuildServiceSpec spec) { - spec.getParameters().getExecutable().set(executable); - } - }) - .get() - .invoke(project, failedTo, unloggedArgs, loggedArgs); + try (ConjureRunnerResource.ConjureRunner runner = ConjureRunnerResource.createNewRunner(executable)) { + runner.invoke(project, failedTo, unloggedArgs, loggedArgs); + } catch (IOException e) { + throw new RuntimeException(e); + } } private GradleExecUtils() {}