[jira] [Commented] (CXF-7923) String.split via fastpath instead of precompiled Pattern

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (CXF-7923) String.split via fastpath instead of precompiled Pattern

JIRA jira@apache.org

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

ASF GitHub Bot commented on CXF-7923:
-------------------------------------

coheigea commented on a change in pull request #481: CXF-7923 String.split via fastpath instead of precompiled Pattern
URL: https://github.com/apache/cxf/pull/481#discussion_r239783133
 
 

 ##########
 File path: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
 ##########
 @@ -254,10 +257,15 @@ public MediaType getMediaType() {
         return getHeaderValues(headerName, originalValue, DEFAULT_SEPARATOR);
     }
 
-    private List<String> getHeaderValues(String headerName, String originalValue, String sep) {
+    private static List<String> getHeaderValues(String headerName, String originalValue, String sep) {
         if (!originalValue.contains(QUOTE)
             || HEADERS_WITH_POSSIBLE_QUOTES.contains(headerName)) {
-            String[] ls = StringUtils.split(originalValue, sep);
+            final String[] ls;
+            if (COOKIE_SEPARATOR_CRLF_EXPRESSION != sep) {
+                ls = originalValue.split(sep);
+            } else {
+                ls = COOKIE_SEPARATOR_CRLF_PATTERN.split(originalValue);
+            }
 
 Review comment:
   I just have a minor reservation about this change. If the user specifies a custom separator that is larger than one character, then String.split will create a Pattern each time this is evaluated. Maybe instead we should move the cache of Patterns internally into this class to avoid this?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


> String.split via fastpath instead of precompiled Pattern
> --------------------------------------------------------
>
>                 Key: CXF-7923
>                 URL: https://issues.apache.org/jira/browse/CXF-7923
>             Project: CXF
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 3.2.7
>            Reporter: Alexey Markevich
>            Assignee: Alexey Markevich
>            Priority: Major
>             Fix For: 3.3.0
>
>
> Initial PR https://github.com/apache/cxf/pull/479



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)