lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [1/2] lucenenet git commit: More .NETization
Date Mon, 19 Jan 2015 18:00:49 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master eef038634 -> 40b5ade8b


More .NETization

In particular, copying the keys in a proper way


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/97f2fdb4
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/97f2fdb4
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/97f2fdb4

Branch: refs/heads/master
Commit: 97f2fdb4ad8ada36b5d7049733d326486effa371
Parents: eef0386
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Mon Jan 19 19:58:11 2015 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Mon Jan 19 19:58:11 2015 +0200

----------------------------------------------------------------------
 .../Store/MockDirectoryWrapper.cs                       | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/97f2fdb4/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs b/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
index e7e292f..3ea5e4f 100644
--- a/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
+++ b/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
@@ -1,3 +1,4 @@
+using System.Collections.Concurrent;
 using NUnit.Framework;
 using System;
 using System.Collections.Generic;
@@ -83,7 +84,7 @@ namespace Lucene.Net.Store
 
         // use this for tracking files for crash.
         // additionally: provides debugging information in case you leave one open
-        private IDictionary<IDisposable, Exception> OpenFileHandles = new ConcurrentHashMap<IDisposable,
Exception>();
+        private readonly ConcurrentDictionary<IDisposable, Exception> OpenFileHandles
= new ConcurrentDictionary<IDisposable, Exception>();
 
         // NOTE: we cannot initialize the Map here due to the
         // order in which our constructor actually does this
@@ -293,8 +294,8 @@ namespace Lucene.Net.Store
                 UnSyncedFiles = new HashSet<string>();
                 // first force-close all files, so we can corrupt on windows etc.
                 // clone the file map, as these guys want to remove themselves on close.
-                IDictionary<IDisposable, Exception> m = new HashMap<IDisposable,
Exception>(OpenFileHandles);
-                foreach (IDisposable f in m.Keys)
+                var m = OpenFileHandles.Keys.ToArray();
+                foreach (IDisposable f in m)
                 {
                     try
                     {
@@ -541,7 +542,7 @@ namespace Lucene.Net.Store
         {
             lock (this)
             {
-                foreach (KeyValuePair<IDisposable, Exception> ent in OpenFileHandles)
+                foreach (var ent in OpenFileHandles)
                 {
                     if (input && ent.Key is MockIndexInputWrapper && ((MockIndexInputWrapper)ent.Key).Name.Equals(name))
                     {
@@ -1082,7 +1083,8 @@ namespace Lucene.Net.Store
                     if (v == 1)
                     {
                         OpenFiles.Remove(name);
-                        OpenFileHandles.Remove(c);
+                        Exception _;
+                        OpenFileHandles.TryRemove(c, out _);
                     }
                     else
                     {


Mime
View raw message