aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2016-12-29 21:49:56 +0000
committerGravatar John Cater <jcater@google.com>2017-01-03 15:03:05 +0000
commit112840b4d6fafd04e2381a2e52fbad848a818ea6 (patch)
treef82825c5b02480612178f8238812590925c67909 /src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java
parentc31f351a191d6927a6483384826297e5549cf426 (diff)
Remove WalkableGraph#exists and allow WalkableGraph#getValue and WalkableGraph#getException to be given non-existent keys without crashing. Add WalkableGraph#isCycle to fill the gap in testing for the difference between non-existence and depending on a cycle.
-- PiperOrigin-RevId: 143205289 MOS_MIGRATED_REVID=143205289
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java
index ae7aa9dcad..551b098e47 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java
@@ -43,6 +43,7 @@ import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.graph.Digraph;
import com.google.devtools.build.lib.packages.BuildFileContainsErrorsException;
import com.google.devtools.build.lib.packages.DependencyFilter;
+import com.google.devtools.build.lib.packages.NoSuchPackageException;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.packages.NoSuchThingException;
import com.google.devtools.build.lib.packages.Package;
@@ -728,9 +729,6 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target>
public Target getTarget(Label label)
throws TargetNotFoundException, QueryException, InterruptedException {
SkyKey packageKey = PackageValue.key(label.getPackageIdentifier());
- if (!graph.exists(packageKey)) {
- throw new QueryException(packageKey + " does not exist in graph");
- }
try {
PackageValue packageValue = (PackageValue) graph.getValue(packageKey);
if (packageValue != null) {
@@ -740,8 +738,16 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target>
}
return packageValue.getPackage().getTarget(label.getName());
} else {
- throw (NoSuchThingException) Preconditions.checkNotNull(
- graph.getException(packageKey), label);
+ NoSuchThingException exception = (NoSuchThingException) graph.getException(packageKey);
+ if (exception != null) {
+ throw exception;
+ }
+ if (graph.isCycle(packageKey)) {
+ throw new NoSuchPackageException(
+ label.getPackageIdentifier(), "Package depends on a cycle");
+ } else {
+ throw new QueryException(packageKey + " does not exist in graph");
+ }
}
} catch (NoSuchThingException e) {
throw new TargetNotFoundException(e);