retrieveTeamDynamixGroupByName crashes when no exact match

XMLWordPrintable

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Minor
    • 6.1.0, 4.22.1, 7.0.1
    • Affects Version/s: 7.0.1
    • Component/s: None
    • None

      The retrieveTeamDynamixGroupByName method searches TeamDynamix using NameLike, which does a fuzzy/like match. The API may return groups that contain the name but don't match exactly. The code then filters for an exact match:
       {{while (iterator.hasNext()) {JsonNode groupNode = iterator.next();TeamDynamixGroup teamDynamixGroup = TeamDynamixGroup.fromJson(groupNode);if (StringUtils.equals(teamDynamixGroup.getName(), groupName)) { groups.add(teamDynamixGroup);}}if (groups.size() > 1)

      {throw new RuntimeException("How can there be more than one group...");}

      return groups.get(0); // <-- crashes if groups is empty}}
       
      If the API returns results (so we don't hit the early return null on line 749-751) but none match exactly, groups is empty and groups.get(0) throws IndexOutOfBoundsException.

      For example, searching for group name "Test" — the API might return "Test Group" and "My Test" via the like match, but neither equals "Test" exactly, so the filtered list is empty.

      The fix would be:
       return groups.size() == 1 ? groups.get(0) : null;

            Assignee:
            Chris Hyzer
            Reporter:
            Chris Hyzer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: