Skip to content

Commit

Permalink
Revert optimization that sometimes caused infinite loops in TreeMaps (#…
Browse files Browse the repository at this point in the history
…793)

Revert a performance optimization for large builds that sometimes resulted in hangs due to infinite loops in TreeMap#get.
  • Loading branch information
AlexLandau authored Jun 12, 2021
1 parent 3287599 commit 2f57499
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-793.v2.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ interface ConjureRunner extends Closeable {
void invoke(Project project, String failedTo, List<String> unloggedArgs, List<String> loggedArgs);
}

private static ConjureRunner createNewRunner(File executable) throws IOException {
static ConjureRunner createNewRunner(File executable) throws IOException {
Optional<StartScriptInfo> maybeJava = ReverseEngineerJavaStartScript.maybeParseStartScript(executable.toPath());
if (maybeJava.isPresent()) {
ReverseEngineerJavaStartScript.StartScriptInfo info = maybeJava.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> unloggedArgs, List<String> 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<BuildServiceSpec<Params>>() {
@Override
public void execute(BuildServiceSpec<Params> 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() {}
Expand Down

0 comments on commit 2f57499

Please sign in to comment.