You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2017/03/08 23:12:24 UTC
[22/50] [abbrv] activemq-nms-openwire git commit: Merged revision(s)
1689927 from activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.7.x:
Apply patch to improve ID parsing to avoid mis-parsing hostnames with
hyphens. Thanks, Andrea Montemaggio! Fixe
Merged revision(s) 1689927 from activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.7.x:
Apply patch to improve ID parsing to avoid mis-parsing hostnames with hyphens. Thanks, Andrea Montemaggio!
Fixes [AMQNET-398]. (See https://issues.apache.org/jira/browse/AMQNET-398)
Project: http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/commit/aba1ae0f
Tree: http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/tree/aba1ae0f
Diff: http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/diff/aba1ae0f
Branch: refs/heads/master
Commit: aba1ae0fb960e5c889c5a2e6378ac7255f95367d
Parents: ecc841b
Author: Jim Gomes <jg...@apache.org>
Authored: Wed Jul 8 18:16:34 2015 +0000
Committer: Jim Gomes <jg...@apache.org>
Committed: Wed Jul 8 18:16:34 2015 +0000
----------------------------------------------------------------------
src/main/csharp/NetTxConnection.cs | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/blob/aba1ae0f/src/main/csharp/NetTxConnection.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/NetTxConnection.cs b/src/main/csharp/NetTxConnection.cs
index 8f1976c..8005e2c 100644
--- a/src/main/csharp/NetTxConnection.cs
+++ b/src/main/csharp/NetTxConnection.cs
@@ -16,6 +16,7 @@
*/
using System;
+using System.Text.RegularExpressions;
using System.Transactions;
using Apache.NMS.ActiveMQ.Transport;
using Apache.NMS.ActiveMQ.Util;
@@ -95,18 +96,20 @@ namespace Apache.NMS.ActiveMQ
private static Guid GuidFromId(string id)
{
- // Remove the ID: prefix, that's non-unique to be sure
- string resId = id.TrimStart("ID:".ToCharArray());
-
- // Remaing parts should be host-port-timestamp-instance:sequence
- string[] parts = resId.Split(":-".ToCharArray());
-
+ MatchCollection matches = Regex.Matches(id, @"(\d+)-(\d+)-(\d+):(\d+)$");
+ if(0 == matches.Count)
+ {
+ throw new FormatException(string.Format("Unable to extract a GUID from string '{0}'", id));
+ }
+
+ GroupCollection groups = matches[0].Groups;
+
// We don't use the hostname here, just the remaining bits.
- int a = Int32.Parse(parts[parts.Length-4]);
- short b = Int16.Parse(parts[parts.Length-2]);
- short c = Int16.Parse(parts[parts.Length-1]);
- byte[] d = System.BitConverter.GetBytes(Int64.Parse(parts[parts.Length-3]));
-
+ int a = Int32.Parse(groups[1].Value);
+ short b = Int16.Parse(groups[3].Value);
+ short c = Int16.Parse(groups[4].Value);
+ byte[] d = BitConverter.GetBytes(Int64.Parse(groups[2].Value));
+
return new Guid(a, b, c, d);
}
}