Skip to content

Commit

Permalink
Fix an aquery crash with Aspect.
Browse files Browse the repository at this point in the history
AspectValue#getAction(int i) should only be used _after_ execution. Calling it
before would cause an IllegalStateException in case of CppCompileActionTemplate.

RELNOTES: None
PiperOrigin-RevId: 319378046
  • Loading branch information
joeleba authored and copybara-github committed Jul 2, 2020
1 parent e6dd345 commit cb2ddb3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
Expand Down Expand Up @@ -80,15 +79,14 @@ public void processOutput(Iterable<ConfiguredTargetValue> partialResult)
options.includeCommandline |= options.includeParamFiles;

for (ConfiguredTargetValue configuredTargetValue : partialResult) {
List<ActionAnalysisMetadata> actions = configuredTargetValue.getActions();
for (ActionAnalysisMetadata action : actions) {
for (ActionAnalysisMetadata action : configuredTargetValue.getActions()) {
writeAction(action, printStream);
}
if (options.useAspects) {
if (configuredTargetValue.getConfiguredTarget() instanceof RuleConfiguredTarget) {
for (AspectValue aspectValue : accessor.getAspectValues(configuredTargetValue)) {
for (int i = 0; i < aspectValue.getNumActions(); i++) {
writeAction(aspectValue.getAction(i), printStream);
for (ActionAnalysisMetadata action : aspectValue.getActions()) {
writeAction(action, printStream);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
import com.google.devtools.build.lib.actions.ActionExecutionMetadata;
import com.google.devtools.build.lib.actions.ActionKeyContext;
Expand Down Expand Up @@ -243,8 +242,7 @@ public void dumpAspect(AspectValue aspectValue, ConfiguredTargetValue configured
if (!includeInActionGraph(configuredTarget.getLabel().toString())) {
return;
}
for (int i = 0; i < aspectValue.getNumActions(); i++) {
Action action = aspectValue.getAction(i);
for (ActionAnalysisMetadata action : aspectValue.getActions()) {
dumpSingleAction(configuredTarget, action);
}
}
Expand All @@ -255,8 +253,7 @@ public void dumpConfiguredTarget(ConfiguredTargetValue configuredTargetValue)
if (!includeInActionGraph(configuredTarget.getLabel().toString())) {
return;
}
List<ActionAnalysisMetadata> actions = configuredTargetValue.getActions();
for (ActionAnalysisMetadata action : actions) {
for (ActionAnalysisMetadata action : configuredTargetValue.getActions()) {
dumpSingleAction(configuredTarget, action);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
import com.google.devtools.build.lib.actions.ActionExecutionMetadata;
import com.google.devtools.build.lib.actions.ActionKeyContext;
Expand Down Expand Up @@ -239,8 +238,7 @@ public void dumpAspect(AspectValue aspectValue, ConfiguredTargetValue configured
if (!includeInActionGraph(configuredTarget.getLabel().toString())) {
return;
}
for (int i = 0; i < aspectValue.getNumActions(); i++) {
Action action = aspectValue.getAction(i);
for (ActionAnalysisMetadata action : aspectValue.getActions()) {
dumpSingleAction(configuredTarget, action);
}
}
Expand All @@ -251,8 +249,7 @@ public void dumpConfiguredTarget(ConfiguredTargetValue configuredTargetValue)
if (!includeInActionGraph(configuredTarget.getLabel().toString())) {
return;
}
List<ActionAnalysisMetadata> actions = configuredTargetValue.getActions();
for (ActionAnalysisMetadata action : actions) {
for (ActionAnalysisMetadata action : configuredTargetValue.getActions()) {
dumpSingleAction(configuredTarget, action);
}
}
Expand Down

0 comments on commit cb2ddb3

Please sign in to comment.