var cloudAccount = GetStorageAccount();
var localCache = new DirectoryInfo("c:\\isLockedTest.txt");
var azureContainer = "azurelocktest";
var cacheDirectory = new SimpleFSDirectory(localCache);
var azureDirectory =
new AzureDirectory(cloudAccount, azureContainer, cacheDirectory);
var analyzer = new StandardAnalyzer(Version.LUCENE_30);
var indexWriter = new IndexWriter(azureDirectory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
Console.WriteLine("Writer 2 created.");
Console.WriteLine($"IsLocked: {IndexWriter.IsLocked(azureDirectory)}");
indexWriter.Dispose();
Console.WriteLine("Writer disposed");
Console.WriteLine($"IsLocked: {IndexWriter.IsLocked(azureDirectory)}");
indexWriter = new IndexWriter(azureDirectory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
Console.WriteLine("Writer 2 created.");
Console.WriteLine($"IsLocked: {IndexWriter.IsLocked(azureDirectory)}");
IndexWriter.Unlock(azureDirectory);
Console.WriteLine("Directory unlocked");
Console.WriteLine($"IsLocked: {IndexWriter.IsLocked(azureDirectory)}");
AzureLock.IsLocked method returns incorrect result. If directory is locked it returns FALSE, if not locked it returns TRUE.
Looks like this line has wrong condition: https://github.com/azure-contrib/AzureDirectory/blob/master/AzureDirectory/AzureLock.cs#L43
See example code below, which outputs to: