From ec150609e486a4a99e83012553520f4f34e18fc1 Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Fri, 23 Mar 2018 13:54:22 -0700 Subject: [PATCH] Fixed AutofillServiceHelper.assertValid() so it throws the right exception. Test: atest FillResponseTest SaveInfoTest Bug: 76097200 Change-Id: Id643007e2d038cc6948cdb8d66c5454048d5f632 --- .../android/service/autofill/AutofillServiceHelper.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/java/android/service/autofill/AutofillServiceHelper.java b/core/java/android/service/autofill/AutofillServiceHelper.java index bbaebff439fb5..13fedba1dde76 100644 --- a/core/java/android/service/autofill/AutofillServiceHelper.java +++ b/core/java/android/service/autofill/AutofillServiceHelper.java @@ -26,7 +26,13 @@ final class AutofillServiceHelper { static AutofillId[] assertValid(@Nullable AutofillId[] ids) { Preconditions.checkArgument(ids != null && ids.length > 0, "must have at least one id"); - return Preconditions.checkArrayElementsNotNull(ids, "ids"); + // Can't use Preconditions.checkArrayElementsNotNull() because it throws NPE instead of IAE + for (int i = 0; i < ids.length; ++i) { + if (ids[i] == null) { + throw new IllegalArgumentException("ids[" + i + "] must not be null"); + } + } + return ids; } private AutofillServiceHelper() {