diff --git a/src/main/java/com/google/devtools/build/lib/query2/PostAnalysisQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/PostAnalysisQueryEnvironment.java index 87cd767f644282..868690a1ba99ed 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/PostAnalysisQueryEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/query2/PostAnalysisQueryEnvironment.java @@ -149,7 +149,7 @@ public QueryEvalResult evaluateQuery( QueryExpression expr, ThreadSafeOutputFormatterCallback callback) throws QueryException, InterruptedException, IOException { beforeEvaluateQuery(); - return super.evaluateQuery(expr, callback); + return evaluateQueryInternal(expr, callback); } private void beforeEvaluateQuery() throws QueryException { 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 88064577df4982..fc0fee6ce2e8d2 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 @@ -514,7 +514,7 @@ public QueryEvalResult evaluateQuery( BatchStreamedCallback batchCallback = new BatchStreamedCallback( callback, BATCH_CALLBACK_SIZE, createUniquifierForOuterBatchStreamedCallback(expr)); - return super.evaluateQuery(expr, batchCallback); + return evaluateQueryInternal(expr, batchCallback); } Map> targetifyValues(Map> input) @@ -1080,8 +1080,7 @@ public void buildTransitiveClosure( } @Override - protected void preloadOrThrow(QueryExpression caller, Collection patterns) - throws QueryException, TargetParsingException { + protected final void preloadOrThrow(QueryExpression caller, Collection patterns) { // SkyQueryEnvironment directly evaluates target patterns in #getTarget and similar methods // using its graph, which is prepopulated using the universeScope (see #beforeEvaluateQuery), // so no preloading of target patterns is necessary. diff --git a/src/main/java/com/google/devtools/build/lib/query2/common/AbstractBlazeQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/common/AbstractBlazeQueryEnvironment.java index 751d0b75eb9145..aeaeca80b6cb95 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/common/AbstractBlazeQueryEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/query2/common/AbstractBlazeQueryEnvironment.java @@ -15,6 +15,7 @@ import static com.google.common.util.concurrent.MoreExecutors.directExecutor; import static java.util.concurrent.TimeUnit.MINUTES; +import static java.util.concurrent.TimeUnit.SECONDS; import com.google.common.base.Function; import com.google.common.base.Preconditions; @@ -73,6 +74,8 @@ */ public abstract class AbstractBlazeQueryEnvironment implements QueryEnvironment, AutoCloseable { + private static final GoogleLogger logger = GoogleLogger.forEnclosingClass(); + protected ErrorSensingEventHandler eventHandler; protected final boolean keepGoing; protected final boolean strictScope; @@ -83,8 +86,6 @@ public abstract class AbstractBlazeQueryEnvironment protected final Set settings; protected final List extraFunctions; - private static final GoogleLogger logger = GoogleLogger.forEnclosingClass(); - protected AbstractBlazeQueryEnvironment( boolean keepGoing, boolean strictScope, @@ -131,6 +132,10 @@ protected QueryExpressionContext createEmptyContext() { return QueryExpressionContext.empty(); } + public abstract QueryEvalResult evaluateQuery( + QueryExpression expr, ThreadSafeOutputFormatterCallback callback) + throws QueryException, IOException, InterruptedException; + /** * Evaluate the specified query expression in this environment, streaming results to the given * {@code callback}. {@code callback.start()} will be called before query evaluation and {@code @@ -143,7 +148,7 @@ protected QueryExpressionContext createEmptyContext() { * @throws QueryException if the evaluation failed and {@code --nokeep_going} was in effect * @throws IOException for output formatter failures from {@code callback} */ - public QueryEvalResult evaluateQuery( + protected final QueryEvalResult evaluateQueryInternal( QueryExpression expr, ThreadSafeOutputFormatterCallback callback) throws QueryException, InterruptedException, IOException { EmptinessSensingCallback emptySensingCallback = new EmptinessSensingCallback<>(callback); @@ -330,7 +335,7 @@ public QueryExpression transformParsedQuery(QueryExpression queryExpression) { } @Override - public void handleError( + public final void handleError( QueryExpression expression, String message, DetailedExitCode detailedExitCode) throws QueryException { if (!keepGoing) { @@ -358,6 +363,7 @@ public Map getTargets(Iterable