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)); }