From 04e4564f49eeeafd601ce3320a9cb8a8db659633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Fri, 26 Apr 2024 05:39:03 +0200 Subject: [PATCH] check-flagged-apis: add missing requireNotNull Bug: 334870672 Test: atest --host check-flagged-apis-test Change-Id: Ibffafb504240c82d525105d4678983b30b70592d --- .../src/com/android/checkflaggedapis/Main.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt b/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt index 84564ba34c..c4c5b1168b 100644 --- a/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt +++ b/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt @@ -207,7 +207,10 @@ internal fun parseApiVersions(input: InputStream): Set { // ktfmt doesn't understand the `..<` range syntax; explicitly call .rangeUntil instead for (i in 0.rangeUntil(fields.getLength())) { val field = fields.item(i) - val fieldName = field.getAttribute("name") + val fieldName = + requireNotNull(field.getAttribute("name")) { + "Bad XML: element without name attribute" + } val className = requireNotNull(field.getParentNode()) { "Bad XML: top level element" } .getAttribute("name")