aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2016-06-08 11:02:28 +0000
committerGravatar Yun Peng <pcloudy@google.com>2016-06-08 11:56:43 +0000
commitbf2676211a2594e3fb443a5ff20d060528fe1614 (patch)
tree1d4f9fc3935ec6eaf97c58857f7157f7a6c93438
parent41d9fbb28869c0522709ab56127876f343850e71 (diff)
Stop catching OutOfMemoryErrors when evaluating Skylark BuiltinFunctions.
-- MOS_MIGRATED_REVID=124338362
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java b/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java
index 74a9f4c2bc..eab18ce2be 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.syntax;
+import com.google.common.base.Throwables;
import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.profiler.Profiler;
import com.google.devtools.build.lib.profiler.ProfilerTask;
@@ -25,7 +26,6 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
-import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable;
@@ -157,19 +157,17 @@ public class BuiltinFunction extends BaseFunction {
return invokeMethod.invoke(this, args);
} catch (InvocationTargetException x) {
Throwable e = x.getCause();
+
if (e instanceof EvalException) {
throw ((EvalException) e).ensureLocation(loc);
- } else if (e instanceof InterruptedException) {
- throw (InterruptedException) e;
- } else if (e instanceof ClassCastException
- || e instanceof ExecutionException
- || e instanceof IllegalStateException) {
- throw new EvalException(loc, "in call to " + getName(), e);
} else if (e instanceof IllegalArgumentException) {
throw new EvalException(loc, "Illegal argument in call to " + getName(), e);
- } else {
- throw badCallException(loc, e, args);
}
+ // TODO(bazel-team): replace with Throwables.throwIfInstanceOf once Guava 20 is released.
+ Throwables.propagateIfInstanceOf(e, InterruptedException.class);
+ // TODO(bazel-team): replace with Throwables.throwIfUnchecked once Guava 20 is released.
+ Throwables.propagateIfPossible(e);
+ throw badCallException(loc, e, args);
} catch (IllegalArgumentException e) {
// Either this was thrown by Java itself, or it's a bug
// To cover the first case, let's manually check the arguments.