From cb1fac88380abef7345ef0ed2e7515e74d0d2dec Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Tue, 2 Aug 2022 09:03:29 -0700 Subject: [PATCH] Fix a crash on a test-only redefinition of ThreadPoolExecutor that doesn't have any parameters PiperOrigin-RevId: 464805116 --- .../bugpatterns/ErroneousThreadPoolConstructorChecker.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/ErroneousThreadPoolConstructorChecker.java b/core/src/main/java/com/google/errorprone/bugpatterns/ErroneousThreadPoolConstructorChecker.java index 4e3877392fd..e32128738da 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/ErroneousThreadPoolConstructorChecker.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/ErroneousThreadPoolConstructorChecker.java @@ -64,6 +64,9 @@ public Description matchNewClass(NewClassTree tree, VisitorState state) { return Description.NO_MATCH; } List arguments = tree.getArguments(); + if (arguments.size() < 2) { + return Description.NO_MATCH; + } Integer corePoolSize = ASTHelpers.constValue(arguments.get(0), Integer.class); Integer maximumPoolSize = ASTHelpers.constValue(arguments.get(1), Integer.class); if (corePoolSize == null || maximumPoolSize == null || corePoolSize.equals(maximumPoolSize)) {