You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Lefteris Tsallas (JIRA)" <ji...@apache.org> on 2016/04/21 12:17:25 UTC

[jira] [Created] (CAMEL-9898) SimpleBuilder throws NullPointerException when replacing string using regexAll method and the regex contains }

Lefteris Tsallas created CAMEL-9898:
---------------------------------------

             Summary: SimpleBuilder throws NullPointerException when replacing string using regexAll method and the regex contains }
                 Key: CAMEL-9898
                 URL: https://issues.apache.org/jira/browse/CAMEL-9898
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.17.0
            Reporter: Lefteris Tsallas
            Priority: Minor


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

{code}
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/{d}/activate");
        assertEquals("http://some/rest/api/12/activate",SimpleBuilder.simple("${header.activateUrl.replaceAll(\"\\{id\\}\",\"12\")}").evaluate(exchange,String.class));
    }
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)