From 6e2de8b2e5b3a7e1558ba5328431300a87953a39 Mon Sep 17 00:00:00 2001 From: Robert Greig Date: Fri, 5 Jan 2007 11:56:51 +0000 Subject: Qpid-238 patch applied. Strange workaround for non-existant bug in string.Split removed. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@492998 13f79535-47bb-0310-9956-ffa450edef68 --- .../Client/Handler/ConnectionStartMethodHandler.cs | 2 +- .../Client/Message/AbstractQmsMessage.cs | 44 +++++++++------------- 2 files changed, 19 insertions(+), 27 deletions(-) (limited to 'dotnet') diff --git a/dotnet/Qpid.Client/Client/Handler/ConnectionStartMethodHandler.cs b/dotnet/Qpid.Client/Client/Handler/ConnectionStartMethodHandler.cs index 2bba8662bb..e88ff3ddbd 100644 --- a/dotnet/Qpid.Client/Client/Handler/ConnectionStartMethodHandler.cs +++ b/dotnet/Qpid.Client/Client/Handler/ConnectionStartMethodHandler.cs @@ -70,7 +70,7 @@ namespace Qpid.Client.Handler throw new AMQException("Locales is not defined in Connection Start method"); } string allLocales = Encoding.ASCII.GetString(body.Locales); - string[] locales = allLocales.Split(new char[] { ' ' }); + string[] locales = allLocales.Split(' '); string selectedLocale; if (locales != null && locales.Length > 0) { diff --git a/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs b/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs index efbeb9edcb..fe0915d4d6 100644 --- a/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs +++ b/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs @@ -193,41 +193,33 @@ namespace Qpid.Client.Message ContentHeaderProperties.ReplyTo = encodedDestination; } + /// + /// Splits a replyto field containing an exchange name followed by a ':', followed by a routing key into the exchange name and + /// routing key seperately. The exchange name may be empty in which case the empty string is returned. If the exchange name is + /// empty the replyto field is expected to being with ':'. + /// + /// Anyhting other than a two part replyto field sperated with a ':' will result in an exception. + /// + /// + /// The encoded replyto field to split. + /// A reference to update with the extracted routing key. + /// + /// The exchange name or the empty string when no exchange name is specified. private static string GetExchangeName(string replyToEncoding, out string routingKey) { - string[] split = replyToEncoding.Split(new char[':']); - if (_log.IsDebugEnabled) - { - _log.Debug(string.Format("replyToEncoding = '{0}'", replyToEncoding)); - _log.Debug(string.Format("split = {0}", split)); - _log.Debug(string.Format("split.Length = {0}", split.Length)); - } - if (split.Length == 1) - { - // Using an alternative split implementation here since it appears that string.Split - // is broken in .NET. It doesn't split when the first character is the delimiter. - // Here we check for the first character being the delimiter. This handles the case - // where ExchangeName is empty (i.e. sends will be to the default exchange). - if (replyToEncoding[0] == ':') - { - split = new string[2]; - split[0] = null; - split[1] = replyToEncoding.Substring(1); - if (_log.IsDebugEnabled) - { - _log.Debug("Alternative split method..."); - _log.Debug(string.Format("split = {0}", split)); - _log.Debug(string.Format("split.Length = {0}", split.Length)); - } - } - } + // Split the replyto field on a ':' + string[] split = replyToEncoding.Split(':'); + + // Ensure that the replyto field argument only consisted of two parts. if (split.Length != 2) { throw new QpidException("Illegal value in ReplyTo property: " + replyToEncoding); } + // Extract the exchange name and routing key from the split replyto field. string exchangeName = split[0]; routingKey = split[1]; + return exchangeName; } -- cgit v1.2.1