From cd55bef010f63843d7bf37a7d4edd55167d133f4 Mon Sep 17 00:00:00 2001 From: asvitkine Date: Wed, 5 Jul 2023 11:00:08 -0400 Subject: [PATCH] Fix 2.6 NoSuchElementException in AA code. This would happen if a unit has special chars in its aaType, causing it to be evaluated as a regex instead of an exact match. This specifically broke the code pattern (e.g. in FiringGroupSplitterAa): final List typeAas = UnitAttachment.getAllOfTypeAas(aaUnits); for (final String typeAa : typeAas) { final Collection firingUnits = CollectionUtils.getMatches(aaUnits, Matches.unitIsAaOfTypeAa(typeAa)); Causing an empty `firingUnits` due to typeAa being evaluated as a regex. I checked all the callsites and verified none of them actually require the regex behavior. Fixes: https://github.com/triplea-game/triplea/issues/11458 --- .../src/main/java/games/strategy/triplea/delegate/Matches.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/Matches.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/Matches.java index 1edf0fbe750..94c55ad8049 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/Matches.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/Matches.java @@ -669,7 +669,7 @@ private static Predicate unitTypeCanBeHitByAaFire( } public static Predicate unitIsAaOfTypeAa(final String typeAa) { - return u -> u.getUnitAttachment().getTypeAa().matches(typeAa); + return u -> u.getUnitAttachment().getTypeAa().equals(typeAa); } public static Predicate unitAaShotDamageableInsteadOfKillingInstantly() {