activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r1689928 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk: ./ src/main/csharp/NetTxConnection.cs
Date Wed, 08 Jul 2015 18:16:35 GMT
Author: jgomes
Date: Wed Jul  8 18:16:34 2015
New Revision: 1689928

URL: http://svn.apache.org/r1689928
Log:
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)

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/   (props changed)
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnection.cs

Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul  8 18:16:34 2015
@@ -1,4 +1,4 @@
 /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x:1082291,1135831,1137081,1171843,1171874,1177390,1177395,1186568,1187123,1238881,1293360,1294890,1295257,1311395,1312026,1374469,1375295,1376782
-/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.7.x:1689923
+/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.7.x:1689923,1689927
 /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/tags/1.0.0:692591,693525
 /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/tags/1.1.0:788230,788233,790183

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnection.cs?rev=1689928&r1=1689927&r2=1689928&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnection.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnection.cs
Wed Jul  8 18:16:34 2015
@@ -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);
         }
     }



Mime
View raw message