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 2011/01/28 18:04:56 UTC
svn commit: r1064779 -
/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transactions/RecoveryFileLogger.cs
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
{