activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1064779 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transactions/RecoveryFileLogger.cs
Date Fri, 28 Jan 2011 17:04:56 GMT
Author: tabish
Date: Fri Jan 28 17:04:55 2011
New Revision: 1064779

URL: http://svn.apache.org/viewvc?rev=1064779&view=rev
Log:
Fix some issues with finding the file and removing it.

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transactions/RecoveryFileLogger.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transactions/RecoveryFileLogger.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transactions/RecoveryFileLogger.cs?rev=1064779&r1=1064778&r2=1064779&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transactions/RecoveryFileLogger.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transactions/RecoveryFileLogger.cs
Fri Jan 28 17:04:55 2011
@@ -30,13 +30,13 @@ namespace Apache.NMS.ActiveMQ.Transactio
     {
         private string location;
         private string resourceManagerId;
-        private object syncRoot = new object();
+        private readonly object syncRoot = new object();
 
         public RecoveryFileLogger()
         {
             // Set the path by default to the location of the executing assembly.
             // May need to change this to current working directory, not sure.
-            this.location = Assembly.GetExecutingAssembly().Location;
+            this.location = "";
         }
 
         /// <summary>
@@ -70,12 +70,11 @@ namespace Apache.NMS.ActiveMQ.Transactio
             {
                 lock (syncRoot)
                 {
-                    string filename = Location + ResourceManagerId + ".bin";
                     RecoveryInformation info = new RecoveryInformation(xid, recoveryInformation);
-                    Tracer.Debug("Serializing Recovery Info to file: " + filename);
+                    Tracer.Debug("Serializing Recovery Info to file: " + Filename);
 
                     IFormatter formatter = new BinaryFormatter();
-                    using (FileStream recoveryLog = new FileStream(filename, FileMode.OpenOrCreate,
FileAccess.Write))
+                    using (FileStream recoveryLog = new FileStream(Filename, FileMode.OpenOrCreate,
FileAccess.Write))
                     {
                         formatter.Serialize(recoveryLog, info);
                     }
@@ -93,7 +92,7 @@ namespace Apache.NMS.ActiveMQ.Transactio
             KeyValuePair<XATransactionId, byte[]>[] result = new KeyValuePair<XATransactionId,
byte[]>[0];
             RecoveryInformation info = TryOpenRecoveryInfoFile();
 
-            if(result != null)
+            if (info != null)
             {
                 result = new KeyValuePair<XATransactionId, byte[]>[1];
                 result[0] = new KeyValuePair<XATransactionId, byte[]>(info.Xid, info.TxRecoveryInfo);
@@ -106,12 +105,10 @@ namespace Apache.NMS.ActiveMQ.Transactio
         {
             lock (syncRoot)
             {
-                string filename = Location + ResourceManagerId + ".bin";
-
                 try
                 {
-                    Tracer.Debug("Attempting to remove stale Recovery Info file: " + filename);
-                    File.Delete(filename);
+                    Tracer.Debug("Attempting to remove stale Recovery Info file: " + Filename);
+                    File.Delete(Filename);
                 }
                 catch(Exception ex)
                 {
@@ -125,12 +122,10 @@ namespace Apache.NMS.ActiveMQ.Transactio
         {
             lock (syncRoot)
             {
-                string filename = Location + ResourceManagerId + ".bin";
-
                 try
                 {
-                    Tracer.Debug("Attempting to remove stale Recovery Info file: " + filename);
-                    File.Delete(filename);
+                    Tracer.Debug("Attempting to remove stale Recovery Info file: " + Filename);
+                    File.Delete(Filename);
                 }
                 catch(Exception ex)
                 {
@@ -147,6 +142,11 @@ namespace Apache.NMS.ActiveMQ.Transactio
 
         #region Recovery File Opeations
 
+        private string Filename
+        {
+            get { return Location + ResourceManagerId + ".bin"; }
+        }
+
         [Serializable]
         private sealed class RecoveryInformation
         {



Mime
View raw message