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

Simplify exception handling in JavaCompileActionContext #25389

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.devtools.build.lib.view.proto.Deps;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.concurrent.ConcurrentHashMap;

/** Context for compiling Java files. */
Expand All @@ -30,26 +29,18 @@ public class JavaCompileActionContext implements ActionContext {
Deps.Dependencies getDependencies(
Artifact jdepsFile, ActionExecutionContext actionExecutionContext) throws IOException {
// TODO(djasper): Investigate caching across builds.
try {
// The cache value computation is potentially expensive, e.g. when we have
// to download an input with actionFS, so we are explicitly not using
// computeIfAbsent here.
// The downside is that potentially we parse the same jdepsFile twice, but
// at least we are not blocking all other threads on the lock for the
// cache.
Deps.Dependencies deps = cache.get(jdepsFile);
if (deps != null) {
return deps;
}
try (InputStream input = actionExecutionContext.getInputPath(jdepsFile).getInputStream()) {
deps = Deps.Dependencies.parseFrom(input);
cache.putIfAbsent(jdepsFile, deps);
return deps;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
} catch (UncheckedIOException e) {
throw e.getCause();
// The cache value computation is potentially expensive, e.g. when we have to download an input
// with actionFS, so we are explicitly not using computeIfAbsent here. The downside is that
// potentially we parse the same jdepsFile twice, but at least we are not blocking all other
// threads on the lock for the cache.
Deps.Dependencies deps = cache.get(jdepsFile);
if (deps != null) {
return deps;
}
try (InputStream input = actionExecutionContext.getInputPath(jdepsFile).getInputStream()) {
deps = Deps.Dependencies.parseFrom(input);
cache.putIfAbsent(jdepsFile, deps);
return deps;
}
}

Expand Down
Loading