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] [Updated] (CAMEL-10085) UnsafeUriCharactersEncoder.checkRAW compiles regex pattern every call
Date Fri, 01 Jul 2016 07:24:11 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-10085?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Claus Ibsen updated CAMEL-10085:
--------------------------------
    Fix Version/s:     (was: 2.17.2)
                   2.17.3

> UnsafeUriCharactersEncoder.checkRAW compiles regex  pattern every call
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-10085
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10085
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.17.1
>            Reporter: Mateusz Nowakowski
>            Assignee: Andrea Cosentino
>            Priority: Minor
>             Fix For: 2.17.3, 2.18.0
>
>
> UnsafeUriCharactersEncoder.checkRAW compile regex  pattern every time it is called (and
it is called really often due to stack: 
> DefaultCamelContext.normalizeEndpointUri() -> URISUpport.normalizeUri() -> org.apache.camel.util.UnsafeUriCharactersEncoder.encode()
-> checkRaw() -> Pattern.compile())
> Under high load it leads to decrease performance.
> The easiest fix is to precompile pattern:
> {code}
>     private static Pattern RAW_PATTERN = Pattern.compile("RAW\\([^\\)]+\\)");
> (....)
>     private static List<Pair> checkRAW(String s) {
>         Matcher matcher = RAW_PATTERN.matcher(s);
>         List<Pair> answer = new ArrayList<Pair>();
>         // Check all occurrences
>         while (matcher.find()) {
>             answer.add(new Pair(matcher.start(), matcher.end()));
>         }
>         return answer;
>     }
> {code}



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

Mime
View raw message