aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2016-03-21 22:26:39 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-03-22 08:09:51 +0000
commitb4c00b6eead53ba9381bab12765b2c4ed98a61d1 (patch)
treea9ed7f6457fb0273c8ff0953c121c6d1ce58f638 /src
parentccdbce6585e86aecb5887bb6be17406a0ae61acc (diff)
Don't keep implicit reference to ProtoCompileAction in anonymous inner CustomMultiArgv class.
-- MOS_MIGRATED_REVID=117761242
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileAction.java41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileAction.java
index 4c3b3dbb7b..94aca1cee0 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileAction.java
@@ -261,6 +261,31 @@ public final class ProtoCompileAction {
return builder;
}
+ /**
+ * Static inner class since these objects live into the execution phase and so they must not
+ * keep alive references to the surrounding analysis-phase objects.
+ */
+ private static class ProtoCommandLineArgv extends CustomMultiArgv {
+ private final Iterable<Artifact> transitiveImports;
+
+ ProtoCommandLineArgv(Iterable<Artifact> transitiveImports) {
+ this.transitiveImports = transitiveImports;
+ }
+
+ @Override
+ public Iterable<String> argv() {
+ ImmutableList.Builder<String> builder = ImmutableList.builder();
+ for (Artifact artifact : transitiveImports) {
+ builder.add(
+ "-I"
+ + artifact.getRootRelativePath().getPathString()
+ + "="
+ + artifact.getExecPathString());
+ }
+ return builder.build();
+ }
+ }
+
/* Commandline generator for protoc invocations. */
public CustomCommandLine.Builder protoCompileCommandLine() {
CustomCommandLine.Builder arguments = CustomCommandLine.builder();
@@ -270,21 +295,7 @@ public final class ProtoCompileAction {
arguments.add(ruleContext.getFragment(ProtoConfiguration.class).protocOpts());
// Add include maps
- arguments.add(
- new CustomMultiArgv() {
- @Override
- public Iterable<String> argv() {
- ImmutableList.Builder<String> builder = ImmutableList.builder();
- for (Artifact artifact : supportData.getTransitiveImports()) {
- builder.add(
- "-I"
- + artifact.getRootRelativePath().getPathString()
- + "="
- + artifact.getExecPathString());
- }
- return builder.build();
- }
- });
+ arguments.add(new ProtoCommandLineArgv(supportData.getTransitiveImports()));
for (Artifact src : supportData.getDirectProtoSources()) {
arguments.addPath(src.getRootRelativePath());