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

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

    [ https://issues.apache.org/jira/browse/CAMEL-9898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15251887#comment-15251887 ] 

Claus Ibsen commented on CAMEL-9898:
------------------------------------

You can use groovy or mvel to call such methods.

> 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/{id}/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)