Skip to content

Commit

Permalink
Improve tracking of unattached dependencies
Browse files Browse the repository at this point in the history
When restarting an edge, it is possible that the new state fails to
compute the target node. In some cases, it is important to make sure the
detached edge is effectively tracked as an unattached edge.

Issue #13316
  • Loading branch information
ljacomet committed Jun 5, 2020
1 parent f0203f5 commit 6c307f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Expand Up @@ -181,9 +181,13 @@ void failWith(Throwable err) {
targetNodeSelectionFailure = new ModuleVersionResolveException(dependencyState.getRequested(), err);
}

public void restart() {
public void restart(boolean unattach) {
if (from.isSelected()) {
removeFromTargetConfigurations();
// We now have corner cases that can lead to this restart not succeeding
if (unattach && !selector.getTargetModule().getUnattachedDependencies().contains(this)) {
selector.getTargetModule().addUnattachedDependency(this);
}
attachToTargetConfigurations();
}
}
Expand Down
Expand Up @@ -262,10 +262,10 @@ private void doRestart(ComponentState selected) {
private void restartUnattachedDependencies() {
if (unattachedDependencies.size() == 1) {
EdgeState singleDependency = unattachedDependencies.get(0);
singleDependency.restart();
singleDependency.restart(false);
} else {
for (EdgeState dependency : new ArrayList<>(unattachedDependencies)) {
dependency.restart();
dependency.restart(false);
}
}
}
Expand Down
Expand Up @@ -615,7 +615,7 @@ public boolean isSelected() {

public void evict() {
evicted = true;
restartIncomingEdges();
restartIncomingEdges(false);
}

boolean shouldIncludedInGraphResult() {
Expand Down Expand Up @@ -976,18 +976,18 @@ public void restart(ComponentState selected) {
}
} else {
if (!incomingEdges.isEmpty()) {
restartIncomingEdges();
restartIncomingEdges(true);
}
}
}

private void restartIncomingEdges() {
private void restartIncomingEdges(boolean unattach) {
if (incomingEdges.size() == 1) {
EdgeState singleEdge = incomingEdges.get(0);
singleEdge.restart();
singleEdge.restart(unattach);
} else {
for (EdgeState dependency : new ArrayList<>(incomingEdges)) {
dependency.restart();
dependency.restart(unattach);
}
}
clearIncomingEdges();
Expand Down

0 comments on commit 6c307f6

Please sign in to comment.