Uploaded image for project: 'ngrinder'
  1. ngrinder
  2. NGRINDER-706

Fix the agent resolution bug with regions having same prefix

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2.3
    • Fix Version/s: 3.3
    • Component/s: controller
    • Labels:
      None

      Description

      When retrieving the agents for a region, the following JPA specification is used.

      {code}
      return new Specification<AgentInfo>() {
      @Override
      public Predicate toPredicate(Root<AgentInfo> root, CriteriaQuery<?> query, CriteriaBuilder cb){ Expression<String> regionField = root.get("region").as(String.class); return cb.or(cb.like(regionField, region + "_%"), cb.equal(regionField, region)); }
      };{code}

      In "%", "" indicates the any character so it mistakenly retrieved wrong region when following regions are used.

      • HELLO
      • HELLO2

      When retrieving the HELLO it will matches HELLO2 as well so it will return the agents belonging to HELLO2.
      Fix this providing the escape character like following.

      {code}
      cb.like(regionField, region + "/_%", cb.literal('/')){code}

        Activity

        Hide
        junoyoon JunHo Yoon added a comment -

        Fixed

        Show
        junoyoon JunHo Yoon added a comment - Fixed

          People

          • Assignee:
            junoyoon JunHo Yoon
            Reporter:
            junoyoon JunHo Yoon
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: