From 9ab7ec80b504c51aa237477d24c9b8816c4d5317 Mon Sep 17 00:00:00 2001 From: asteinb Date: Mon, 23 Apr 2018 12:44:52 -0700 Subject: [PATCH] Add error message on empty public resources This should provide more understandable behavior in the case described in https://github.com/bazelbuild/bazel/issues/5077 RELNOTES: none PiperOrigin-RevId: 193968203 --- .../PlaceholderIdFieldInitializerBuilder.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/tools/android/java/com/google/devtools/build/android/PlaceholderIdFieldInitializerBuilder.java b/src/tools/android/java/com/google/devtools/build/android/PlaceholderIdFieldInitializerBuilder.java index ab1dee800dc811..571a59803b0079 100644 --- a/src/tools/android/java/com/google/devtools/build/android/PlaceholderIdFieldInitializerBuilder.java +++ b/src/tools/android/java/com/google/devtools/build/android/PlaceholderIdFieldInitializerBuilder.java @@ -337,13 +337,17 @@ private Map assignTypeIdsForPublic() { "Cannot force ATTR to have type code other than 0x%02x (got 0x%02x from %s)", ATTR_TYPE_ID, reservedTypeSlot, previousResource)); } - allocatedTypeIds.put(currentType, reservedTypeSlot); - ResourceType alreadyAssigned = assignedIds.put(reservedTypeSlot, currentType); - if (alreadyAssigned != null) { - logger.warning( - String.format( - "Multiple type names declared for public type identifier 0x%x (%s vs %s)", - reservedTypeSlot, alreadyAssigned, currentType)); + if (reservedTypeSlot == null) { + logger.warning(String.format("Invalid public resource of type %s - ignoring", currentType)); + } else { + allocatedTypeIds.put(currentType, reservedTypeSlot); + ResourceType alreadyAssigned = assignedIds.put(reservedTypeSlot, currentType); + if (alreadyAssigned != null) { + logger.warning( + String.format( + "Multiple type names declared for public type identifier 0x%x (%s vs %s)", + reservedTypeSlot, alreadyAssigned, currentType)); + } } } return allocatedTypeIds;