Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9898

SimpleBuilder throws NullPointerException when replacing string using regexAll method and the regex contains }

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.17.0
    • Fix Version/s: 2.18.0
    • Component/s: camel-core
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Add this unit test in org.apache.camel.builder.SimpleBuilderTest to reproduce the issue. Only fails when the regex contains }

      public  void testRegexAllWithPlaceHolders() {
              exchange.getIn().setHeader("activateUrl", "http://some/rest/api/(id)/activate");
              assertEquals("http://some/rest/api/12/activate",SimpleBuilder.simple("${header.activateUrl.replaceAll(\"\\(id\\)\",\"12\")}").evaluate(exchange,String.class));
      
              //passes when contains { only
              exchange.getIn().setHeader("activateUrl", "http://some/rest/api/{id/activate");
              assertEquals("http://some/rest/api/12/activate",SimpleBuilder.simple("${header.activateUrl.replaceAll(\"\\{id\",\"12\")}").evaluate(exchange,String.class));
      
      
              String replaced  = "http://some/rest/api/{id}/activate".replaceAll("\\{id\\}","12");
              assertEquals( "http://some/rest/api/12/activate", replaced);
              /// But throws throws NullPointerException when regexALl inside a simple expression
              exchange.getIn().setHeader("activateUrl", "http://some/rest/api/{id}/activate");
              assertEquals("http://some/rest/api/12/activate",SimpleBuilder.simple("${header.activateUrl.replaceAll(\"\\{id\\}\",\"12\")}").evaluate(exchange,String.class));
          }
      

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              ltsall Lefteris Tsallas
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: