camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-9898) SimpleBuilder throws NullPointerException when replacing string using regexAll method and the regex contains }
Date Thu, 21 Apr 2016 18:55:25 GMT

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

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

We can improve the parser to support escaping curly-bracket-end so its not mistakenly taken
as a function end marker.

> 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
>            Assignee: Claus Ibsen
>            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)

Mime
View raw message