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 2397FEC1C for ; Wed, 19 Dec 2012 18:52:22 +0000 (UTC) Received: (qmail 82952 invoked by uid 500); 19 Dec 2012 18:52:21 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 82896 invoked by uid 500); 19 Dec 2012 18:52:21 -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 82889 invoked by uid 99); 19 Dec 2012 18:52:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2012 18:52:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2012 18:52:20 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F2B3623889E0; Wed, 19 Dec 2012 18:51:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1424024 - in /cxf/branches/2.5.x-fixes: common/common/src/main/java/org/apache/cxf/common/util/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ rt/transport... Date: Wed, 19 Dec 2012 18:51:59 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121219185159.F2B3623889E0@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Wed Dec 19 18:51:59 2012 New Revision: 1424024 URL: http://svn.apache.org/viewvc?rev=1424024&view=rev Log: Merged revisions 1424007 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes ........ r1424007 | dkulp | 2012-12-19 13:28:46 -0500 (Wed, 19 Dec 2012) | 10 lines Merged revisions 1423981 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1423981 | dkulp | 2012-12-19 12:43:48 -0500 (Wed, 19 Dec 2012) | 2 lines Start to use some precompiled patterns for common places where we split strings ........ ........ Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Cookies.java cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java cxf/branches/2.5.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java cxf/branches/2.5.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/URISupport.java Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java?rev=1424024&r1=1424023&r2=1424024&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java (original) +++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java Wed Dec 19 18:51:59 2012 @@ -24,14 +24,38 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; public final class StringUtils { - + public static final Map PATTERN_MAP = new HashMap(); + static { + String patterns[] = {"/", " ", ":", "," , ";", "="}; + for (String p : patterns) { + PATTERN_MAP.put(p, Pattern.compile(p)); + } + } + private StringUtils() { } + + public static String[] split(String s, String regex) { + Pattern p = PATTERN_MAP.get(regex); + if (p != null) { + return p.split(s); + } + return s.split(regex); + } + public static String[] split(String s, String regex, int limit) { + Pattern p = PATTERN_MAP.get(regex); + if (p != null) { + return p.split(s, limit); + } + return s.split(regex, limit); + } public static String extract(String string, String startToken, String endToken) { int start = string.indexOf(startToken) + startToken.length(); @@ -112,7 +136,7 @@ public final class StringUtils { public static List getParts(String str, String seperator) { List ret = new ArrayList(); - List parts = Arrays.asList(str.split(seperator)); + List parts = Arrays.asList(split(str, seperator)); for (String part : parts) { if (!isEmpty(part)) { ret.add(part); @@ -122,7 +146,7 @@ public final class StringUtils { } public static String getFirstNotEmpty(String str, String seperator) { - List parts = Arrays.asList(str.split(seperator)); + List parts = Arrays.asList(split(str, seperator)); for (String part : parts) { if (!isEmpty(part)) { return part; Modified: cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=1424024&r1=1424023&r2=1424024&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java (original) +++ cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java Wed Dec 19 18:51:59 2012 @@ -149,9 +149,10 @@ public abstract class AbstractHTTPDestin if (credentials == null || StringUtils.isEmpty(credentials.trim())) { return null; } - String authType = credentials.split(" ")[0]; + String creds[] = StringUtils.split(credentials, " "); + String authType = creds[0]; if ("Basic".equals(authType)) { - String authEncoded = credentials.split(" ")[1]; + String authEncoded = creds[1]; try { String authDecoded = new String(Base64Utility.decode(authEncoded)); int idx = authDecoded.indexOf(':'); Modified: cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Cookies.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Cookies.java?rev=1424024&r1=1424023&r2=1424024&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Cookies.java (original) +++ cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Cookies.java Wed Dec 19 18:51:59 2012 @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.message.Message; import org.apache.cxf.message.MessageUtils; @@ -70,11 +71,11 @@ public class Cookies { } for (String header : headers) { - String[] cookies = header.split(","); + String[] cookies = StringUtils.split(header, ","); for (String cookie : cookies) { - String[] parts = cookie.split(";"); + String[] parts = StringUtils.split(cookie, ";"); - String[] kv = parts[0].split("=", 2); + String[] kv = StringUtils.split(parts[0], "=", 2); if (kv.length != 2) { continue; } @@ -83,7 +84,7 @@ public class Cookies { Cookie newCookie = new Cookie(name, value); for (int i = 1; i < parts.length; i++) { - kv = parts[i].split("=", 2); + kv = StringUtils.split(parts[i], "=", 2); name = kv[0].trim(); value = (kv.length > 1) ? kv[1].trim() : null; if (name.equalsIgnoreCase(Cookie.DISCARD_ATTRIBUTE)) { Modified: cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java?rev=1424024&r1=1424023&r2=1424024&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java (original) +++ cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java Wed Dec 19 18:51:59 2012 @@ -102,7 +102,7 @@ public abstract class AbstractHTTPServle protected static List parseListSequence(String values) { if (values != null) { List list = new LinkedList(); - String[] pathValues = values.split(" "); + String[] pathValues = StringUtils.split(values, " "); for (String value : pathValues) { String theValue = value.trim(); if (theValue.length() > 0) { @@ -119,9 +119,13 @@ public abstract class AbstractHTTPServle if (sequence != null) { sequence = sequence.trim(); Map map = new HashMap(); - String[] pairs = sequence.split(" "); + String[] pairs = StringUtils.split(sequence, " "); for (String pair : pairs) { - String[] value = pair.split("="); + String thePair = pair.trim(); + if (thePair.length() == 0) { + continue; + } + String[] value = StringUtils.split(thePair, "="); if (value.length == 2) { map.put(value[0].trim(), value[1].trim()); } else { Modified: cxf/branches/2.5.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java?rev=1424024&r1=1424023&r2=1424024&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java (original) +++ cxf/branches/2.5.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java Wed Dec 19 18:51:59 2012 @@ -45,6 +45,7 @@ import javax.jms.Topic; import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.common.util.SOAPConstants; +import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.helpers.CastUtils; import org.apache.cxf.helpers.HttpHeaderHelper; import org.apache.cxf.message.MessageUtils; @@ -343,7 +344,7 @@ public final class JMSUtils { String contentType = ct.toLowerCase(); String enc = null; - String[] tokens = contentType.split(";"); + String[] tokens = StringUtils.split(contentType, ";"); for (String token : tokens) { int index = token.indexOf("charset="); if (index >= 0) { Modified: cxf/branches/2.5.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/URISupport.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/URISupport.java?rev=1424024&r1=1424023&r2=1424024&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/URISupport.java (original) +++ cxf/branches/2.5.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/URISupport.java Wed Dec 19 18:51:59 2012 @@ -27,6 +27,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import org.apache.cxf.common.util.StringUtils; + /** * URI utilities. * @@ -114,7 +116,7 @@ public final class URISupport { try { Map rc = new HashMap(); if (uri != null) { - String[] parameters = uri.split("&"); + String[] parameters = StringUtils.split(uri, "&"); for (String parameter : parameters) { int p = parameter.indexOf("="); if (p >= 0) {