aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java
diff options
context:
space:
mode:
authorGravatar Nathan Harmata <nharmata@google.com>2015-10-19 20:08:48 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2015-10-20 16:36:07 +0000
commit98ea68a20ddd58f1ee4bb67410484a1c8794556a (patch)
tree298fc1ff455e6ba37a34e15781f4f3e2e9e41b1f /src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java
parent853cd73b0025fb86b3c042320d824a4eb4447dc4 (diff)
Don't log SchedulerExceptions.
RELNOTES: None -- MOS_MIGRATED_REVID=105787681
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java b/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java
index 5fe85bbf65..7a0ab061ac 100644
--- a/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java
+++ b/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java
@@ -648,25 +648,33 @@ public class AbstractQueueVisitor {
}
}
+ /** Classification of an error thrown by an action. */
+ protected enum ErrorClassification {
+ // All running actions should be stopped.
+ CRITICAL,
+ // Same as CRITICAL, but also log the error.
+ CRITICAL_AND_LOG,
+ // Other running actions should be left alone.
+ NOT_CRITICAL
+ }
+
/**
- * If this returns true, that means the exception {@code e} is critical
- * and all running actions should be stopped. {@link Error}s are always considered critical.
+ * Classifies {@code e}. {@link Error}s are always classified as {@code CRITICAL_AND_LOG}.
*
- * <p>Default value - always false. If different behavior is needed
+ * <p>Default value - always treat errors as {@code NOT_CRITICAL}. If different behavior is needed
* then we should override this method in subclasses.
*
* @param e the exception object to check
*/
- protected boolean isCriticalError(Throwable e) {
- return false;
+ protected ErrorClassification classifyError(Throwable e) {
+ return ErrorClassification.NOT_CRITICAL;
}
- private boolean isCriticalErrorInternal(Throwable e) {
- boolean isCritical = isCriticalError(e) || (e instanceof Error);
- if (isCritical) {
- LOG.log(Level.WARNING, "Found critical error in queue visitor", e);
+ private ErrorClassification classifyErrorInternal(Throwable e) {
+ if (e instanceof Error) {
+ return ErrorClassification.CRITICAL_AND_LOG;
}
- return isCritical;
+ return classifyError(e);
}
/**
@@ -674,7 +682,19 @@ public class AbstractQueueVisitor {
* to stop all jobs inside {@link #awaitTermination(boolean)}.
*/
private synchronized void markToStopAllJobsIfNeeded(Throwable e) {
- if (isCriticalErrorInternal(e) && !jobsMustBeStopped) {
+ boolean critical = false;
+ switch (classifyErrorInternal(e)) {
+ case CRITICAL_AND_LOG:
+ critical = true;
+ LOG.log(Level.WARNING, "Found critical error in queue visitor", e);
+ break;
+ case CRITICAL:
+ critical = true;
+ break;
+ default:
+ break;
+ }
+ if (critical && !jobsMustBeStopped) {
jobsMustBeStopped = true;
synchronized (zeroRemainingTasks) {
zeroRemainingTasks.notify();