Stop holding on to the Action and ActionKeyContext in ActionConflictException. We can construct the exception message eagerly, since it is going to be thrown with very high likelihood in any case.
The complex objects inside it made it hard to serialize.
@@ -63,10 +63,8 @@ public interface MutableActionGraph extends ActionGraph {
*/
final class ActionConflictException extends Exception {
- private final ActionKeyContext actionKeyContext;
private final Artifact artifact;
- private final ActionAnalysisMetadata previousAction;
- private final ActionAnalysisMetadata attemptedAction;
+ private final String suffix;
private static final int MAX_DIFF_ARTIFACTS_TO_REPORT = 5;
@@ -81,10 +79,8 @@ public interface MutableActionGraph extends ActionGraph {
artifact.prettyPrint(),
previousAction.prettyPrint(),
attemptedAction.prettyPrint()));
- this.actionKeyContext = actionKeyContext;
this.artifact = artifact;
- this.previousAction = previousAction;
- this.attemptedAction = attemptedAction;
+ this.suffix = suffix(actionKeyContext, attemptedAction, previousAction);
}
public Artifact getArtifact() {
@@ -96,7 +92,7 @@ public interface MutableActionGraph extends ActionGraph {
"file '"
+ artifact.prettyPrint()
+ "' is generated by these conflicting actions:\n"
- + suffix(actionKeyContext, attemptedAction, previousAction);
+ + suffix;
eventListener.handle(Event.error(msg));
}
