Factor out version assertions in InMemoryNodeEntry, and make those assertions go to logError() so that they can be handled specially by subclasses if desired.
PiperOrigin-RevId: 215624076
diff --git a/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java b/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
index d0f0703..d498c41 100644
--- a/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
+++ b/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
@@ -295,11 +295,7 @@
public synchronized Set<SkyKey> setValue(SkyValue value, Version version)
throws InterruptedException {
Preconditions.checkState(isReady(), "%s %s", this, value);
- // This check may need to be removed when we move to a non-linear versioning sequence.
- Preconditions.checkState(
- this.lastChangedVersion.atMost(version), "%s %s %s", this, version, value);
- Preconditions.checkState(
- this.lastEvaluatedVersion.atMost(version), "%s %s %s", this, version, value);
+ assertVersionCompatibleWhenSettingValue(version, value);
this.lastEvaluatedVersion = version;
if (isDirty() && getDirtyBuildingState().unchangedFromLastBuild(value)) {
@@ -329,6 +325,18 @@
return setStateFinishedAndReturnReverseDepsToSignal();
}
+ protected void assertVersionCompatibleWhenSettingValue(
+ Version version, SkyValue valueForDebugging) {
+ if (!this.lastChangedVersion.atMost(version)) {
+ logError(
+ new IllegalStateException("Bad ch: " + this + ", " + version + ", " + valueForDebugging));
+ }
+ if (!this.lastEvaluatedVersion.atMost(version)) {
+ logError(
+ new IllegalStateException("Bad ev: " + this + ", " + version + ", " + valueForDebugging));
+ }
+ }
+
@Override
public synchronized DependencyState addReverseDepAndCheckIfDone(SkyKey reverseDep) {
if (reverseDep != null) {