cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6813] Minor optimization
Date Wed, 02 Mar 2016 11:19:07 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes ed525fe47 -> c8d77ac8b


[CXF-6813] Minor optimization


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/c8d77ac8
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/c8d77ac8
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/c8d77ac8

Branch: refs/heads/3.1.x-fixes
Commit: c8d77ac8b1d8d5c6307b585409efcdcb52a2ea4d
Parents: ed525fe
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed Mar 2 11:16:45 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Mar 2 11:18:32 2016 +0000

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c8d77ac8/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
index d8dfc66..39f484e 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
@@ -59,18 +59,18 @@ public class MediaTypeHeaderProvider implements HeaderDelegate<MediaType>
{
         int i = mType.indexOf('/');
         if (i == -1) {
             return handleMediaTypeWithoutSubtype(mType.trim());
+        } else if (i == 0) {
+            throw new IllegalArgumentException("Invalid media type string: " + mType);
         }
         
         int paramsStart = mType.indexOf(';', i + 1);
         int end = paramsStart == -1  ? mType.length() : paramsStart;
         
-        String[] parts = mType.substring(0, end).split("/");
-        if (parts.length != 2 || StringUtils.isEmpty(parts[0]) || StringUtils.isEmpty(parts[1]))
{
-            throw new IllegalArgumentException("Can not parse media type string: " + mType);
-        }
-        
         String type = mType.substring(0, i); 
         String subtype = mType.substring(i + 1, end);
+        if (subtype.indexOf("/") != -1) {
+            throw new IllegalArgumentException("Invalid media type string: " + mType);
+        }
         
         Map<String, String> parameters = Collections.emptyMap();
         if (paramsStart != -1) {


Mime
View raw message