aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Philipp Wollermann <philwo@google.com>2016-02-08 14:02:24 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-02-09 12:16:41 +0000
commit2d47eaa13fbb23c38247dad27df8ea8625430ce6 (patch)
tree3f371e7c0aad774154e01ab0fd2a505a713e95ba /src
parent7841576856528c56253f2b5c89bb5885c0c63c9b (diff)
Make The Build Faster: More explicit exception handling in the worker strategy.
-- MOS_MIGRATED_REVID=114102899
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/worker/WorkerPool.java23
-rw-r--r--src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java6
2 files changed, 26 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerPool.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerPool.java
index 03eb7d6a54..bf5e458a23 100644
--- a/src/main/java/com/google/devtools/build/lib/worker/WorkerPool.java
+++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerPool.java
@@ -13,12 +13,15 @@
// limitations under the License.
package com.google.devtools.build.lib.worker;
+import com.google.common.base.Throwables;
import com.google.devtools.build.lib.events.Reporter;
import com.google.devtools.build.lib.vfs.Path;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
+import java.io.IOException;
+
import javax.annotation.concurrent.ThreadSafe;
/**
@@ -47,4 +50,24 @@ final class WorkerPool extends GenericKeyedObjectPool<WorkerKey, Worker> {
public void setVerbose(boolean verbose) {
this.workerFactory.setVerbose(verbose);
}
+
+ @Override
+ public Worker borrowObject(WorkerKey key) throws IOException, InterruptedException {
+ try {
+ return super.borrowObject(key);
+ } catch (Throwable t) {
+ Throwables.propagateIfPossible(t, IOException.class, InterruptedException.class);
+ throw new RuntimeException("unexpected", t);
+ }
+ }
+
+ @Override
+ public void invalidateObject(WorkerKey key, Worker obj) throws IOException, InterruptedException {
+ try {
+ super.invalidateObject(key, obj);
+ } catch (Throwable t) {
+ Throwables.propagateIfPossible(t, IOException.class, InterruptedException.class);
+ throw new RuntimeException("unexpected", t);
+ }
+ }
}
diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java
index c079a8d941..20e0755be0 100644
--- a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java
@@ -186,7 +186,7 @@ final class WorkerSpawnStrategy implements SpawnActionContext {
String.format(
"Worker process sent response with exit code: %d.", response.getExitCode()));
}
- } catch (Exception e) {
+ } catch (IOException e) {
String message =
CommandFailureUtils.describeCommandFailure(
verboseFailures, spawn.getArguments(), env, execRoot.getPathString());
@@ -228,7 +228,7 @@ final class WorkerSpawnStrategy implements SpawnActionContext {
private WorkResponse execInWorker(
EventHandler eventHandler, WorkerKey key, WorkRequest request, int retriesLeft)
- throws Exception {
+ throws IOException, InterruptedException, UserExecException {
Worker worker = null;
WorkResponse response = null;
@@ -244,7 +244,7 @@ final class WorkerSpawnStrategy implements SpawnActionContext {
"Worker process did not return a correct WorkResponse. This is probably caused by a "
+ "bug in the worker, writing unexpected other data to stdout.");
}
- } catch (Exception e) {
+ } catch (IOException | InterruptedException e) {
if (e instanceof InterruptedException) {
// The user pressed Ctrl-C. Get out here quick.
retriesLeft = 0;