Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C78CE18894 for ; Wed, 2 Mar 2016 11:17:03 +0000 (UTC) Received: (qmail 94512 invoked by uid 500); 2 Mar 2016 11:17:03 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 94454 invoked by uid 500); 2 Mar 2016 11:17:03 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 94445 invoked by uid 99); 2 Mar 2016 11:17:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Mar 2016 11:17:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7AB6CDFDE2; Wed, 2 Mar 2016 11:17:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sergeyb@apache.org To: commits@cxf.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: [CXF-6813] Minor optimization Date: Wed, 2 Mar 2016 11:17:03 +0000 (UTC) Repository: cxf Updated Branches: refs/heads/master 15ab1324e -> 647810f68 [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/647810f6 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/647810f6 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/647810f6 Branch: refs/heads/master Commit: 647810f6819deb8848d7e1bf5857cb71190d7f1c Parents: 15ab132 Author: Sergey Beryozkin Authored: Wed Mar 2 11:16:45 2016 +0000 Committer: Sergey Beryozkin Committed: Wed Mar 2 11:16:45 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/647810f6/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 { 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 parameters = Collections.emptyMap(); if (paramsStart != -1) {