Move BatchStreamedCallback's call to OutputFormatterCallback#processOutput outside of the synchronized block.
There's no need for it to be there.
RELNOTES: None
PiperOrigin-RevId: 229394012
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 f988f8f..30fc480 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
@@ -1220,14 +1220,18 @@
public void processOutput(Iterable<Target> partialResult)
throws IOException, InterruptedException {
ImmutableList<Target> uniquifiedTargets = uniquifier.unique(partialResult);
+ Iterable<Target> toProcess = null;
synchronized (pendingLock) {
Preconditions.checkNotNull(pending, "Reuse of the callback is not allowed");
pending.addAll(uniquifiedTargets);
if (pending.size() >= batchThreshold) {
- callback.processOutput(pending);
+ toProcess = pending;
pending = new ArrayList<>();
}
}
+ if (toProcess != null) {
+ callback.processOutput(toProcess);
+ }
}
@Override