lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccurr...@apache.org
Subject [Lucene.Net] svn commit: r1235645 [2/2] - in /incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk: src/contrib/Analyzers/CJK/ src/core/ src/core/Analysis/ src/core/Index/ src/core/QueryParser/ src/core/Search/ src/core/Search/Function/ src/core/Store/ src/core/Sup...
Date Wed, 25 Jan 2012 07:01:47 GMT
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/IndexInput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/IndexInput.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/IndexInput.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/IndexInput.cs Wed
Jan 25 07:01:45 2012
@@ -26,7 +26,7 @@ namespace Lucene.Net.Store
 	/// </summary>
 	/// <seealso cref="Directory">
 	/// </seealso>
-	public abstract class IndexInput : System.ICloneable/*, IDisposable*/
+	public abstract class IndexInput : System.ICloneable, IDisposable
 	{
 		private bool preUTF8Strings; // true if we are reading old (modified UTF8) string format
 		
@@ -218,9 +218,19 @@ namespace Lucene.Net.Store
 			}
 		}
 		
-		
-		/// <summary>Closes the stream to futher operations. </summary>
-		public abstract void  Close();
+		[Obsolete("Use Dispose() instead.")]
+		public void Close()
+		{
+		    Dispose();
+		}
+
+        /// <summary>Closes the stream to futher operations. </summary>
+	    public void Dispose()
+        {
+            Dispose(true);
+        }
+
+	    protected abstract void Dispose(bool disposing);
 		
 		/// <summary>Returns the current position in this file, where the next read will
 		/// occur.

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/Lock.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/Lock.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/Lock.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/Lock.cs Wed Jan 25
07:01:45 2012
@@ -132,7 +132,7 @@ namespace Lucene.Net.Store
 			
 			
 			/// <summary>Constructs an executor that will grab the named lock. </summary>
-			public With(Lock lock_Renamed, long lockWaitTimeout)
+			protected With(Lock lock_Renamed, long lockWaitTimeout)
 			{
 				this.lock_Renamed = lock_Renamed;
 				this.lockWaitTimeout = lockWaitTimeout;

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/MMapDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/MMapDirectory.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/MMapDirectory.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/MMapDirectory.cs Wed
Jan 25 07:01:45 2012
@@ -210,7 +210,7 @@ namespace Lucene.Net.Store
 			return maxBBuf;
 		}
 		
-		private class MMapIndexInput:IndexInput, System.ICloneable
+		private class MMapIndexInput : IndexInput
 		{
 			private void  InitBlock(MMapDirectory enclosingInstance)
 			{
@@ -228,7 +228,8 @@ namespace Lucene.Net.Store
 			
 			private System.IO.MemoryStream buffer;
 			private long length;
-			private bool isClone = false;
+			private bool isClone;
+		    private bool isDisposed;
 			
 			internal MMapIndexInput(MMapDirectory enclosingInstance, System.IO.FileStream raf)
 			{
@@ -289,19 +290,26 @@ namespace Lucene.Net.Store
 				return clone;
 			}
 			
-			public override void  Close()
+			protected override void Dispose(bool isDisposing)
 			{
-				if (isClone || buffer == null)
-					return ;
-				// unmap the buffer (if enabled) and at least unset it for GC
-				try
-				{
-					Enclosing_Instance.CleanMapping(buffer);
-				}
-				finally
-				{
-					buffer = null;
-				}
+                if (isDisposed) return;
+
+                if (isDisposing)
+                {
+                    if (isClone || buffer == null)
+                        return;
+                    // unmap the buffer (if enabled) and at least unset it for GC
+                    try
+                    {
+                        Enclosing_Instance.CleanMapping(buffer);
+                    }
+                    finally
+                    {
+                        buffer = null;
+                    }
+                }
+
+			    isDisposed = true;
 			}
 		}
 		
@@ -328,6 +336,8 @@ namespace Lucene.Net.Store
 			private int[] bufSizes; // keep here, ByteBuffer.size() method is optional
 			
 			private long length;
+
+		    private bool isDisposed;
 			
 			private int curBufIndex;
 			private int maxBufSize;
@@ -450,31 +460,33 @@ namespace Lucene.Net.Store
 				}
 				return clone;
 			}
-			
-			public override void  Close()
-			{
-				if (isClone || buffers == null)
-					return ;
-				try
-				{
-					for (int bufNr = 0; bufNr < buffers.Length; bufNr++)
-					{
-						// unmap the buffer (if enabled) and at least unset it for GC
-						try
-						{
-							Enclosing_Instance.CleanMapping(buffers[bufNr]);
-						}
-						finally
-						{
-							buffers[bufNr] = null;
-						}
-					}
-				}
-				finally
-				{
-					buffers = null;
-				}
-			}
+
+            protected override void Dispose(bool disposing)
+            {
+                if (isDisposed) return;
+                if (isClone || buffers == null)
+                    return;
+                try
+                {
+                    for (int bufNr = 0; bufNr < buffers.Length; bufNr++)
+                    {
+                        // unmap the buffer (if enabled) and at least unset it for GC
+                        try
+                        {
+                            Enclosing_Instance.CleanMapping(buffers[bufNr]);
+                        }
+                        finally
+                        {
+                            buffers[bufNr] = null;
+                        }
+                    }
+                }
+                finally
+                {
+                    buffers = null;
+                }
+                isDisposed = true;
+            }
 		}
 		
 		/// <summary>Creates an IndexInput for the file with the given name. </summary>

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMDirectory.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMDirectory.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMDirectory.cs Wed
Jan 25 07:01:45 2012
@@ -32,7 +32,7 @@ namespace Lucene.Net.Store
 		private const long serialVersionUID = 1L;
 
         internal protected HashMap<string, RAMFile> fileMap = new HashMap<string,
RAMFile>();
-		internal protected long sizeInBytes = 0;
+		internal protected long _sizeInBytes = 0;
 		
 		// *****
 		// Lock acquisition sequence:  RAMDirectory, then RAMFile
@@ -182,7 +182,7 @@ namespace Lucene.Net.Store
 			lock (this)
 			{
 				EnsureOpen();
-				return sizeInBytes;
+				return _sizeInBytes;
 			}
 		}
 		
@@ -198,7 +198,7 @@ namespace Lucene.Net.Store
 				{
 					fileMap.Remove(name);
 					file.directory = null;
-					sizeInBytes -= file.sizeInBytes; 
+					_sizeInBytes -= file.sizeInBytes; 
 				}
 				else
 					throw new System.IO.FileNotFoundException(name);
@@ -215,7 +215,7 @@ namespace Lucene.Net.Store
 				RAMFile existing = fileMap[name];
 				if (existing != null)
 				{
-					sizeInBytes -= existing.sizeInBytes;
+					_sizeInBytes -= existing.sizeInBytes;
 					existing.directory = null;
 				}
 				fileMap[name] = file;
@@ -236,20 +236,12 @@ namespace Lucene.Net.Store
 				throw new System.IO.FileNotFoundException(name);
 			return new RAMInputStream(file);
 		}
-		
-		/// <summary>Closes the store to future operations, releasing associated memory.
</summary>
-		public override void  Close()
-		{
-			isOpen = false;
-			fileMap = null;
-		}
 
-        /// <summary>
-        /// .NET
-        /// </summary>
-        public override void Dispose()
+        /// <summary>Closes the store to future operations, releasing associated memory.
</summary>
+        protected override void Dispose(bool disposing)
         {
-            Close();
+            isOpen = false;
+            fileMap = null;
         }
 
         //public HashMap<string, RAMFile> fileMap_ForNUnit

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMFile.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMFile.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMFile.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMFile.cs Wed Jan
25 07:01:45 2012
@@ -91,7 +91,7 @@ namespace Lucene.Net.Store
             {
                 lock (directory) //{{DIGY}} what if directory gets null in the mean time?
                 {
-                    directory.sizeInBytes += size;
+                    directory._sizeInBytes += size;
                 }
             }
 

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMInputStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMInputStream.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMInputStream.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMInputStream.cs
Wed Jan 25 07:01:45 2012
@@ -23,7 +23,7 @@ namespace Lucene.Net.Store
 	/// <summary> A memory-resident <see cref="IndexInput" /> implementation.
 	/// 
 	/// </summary>
-	public class RAMInputStream : IndexInput, System.ICloneable
+	public class RAMInputStream : IndexInput
 	{
 		internal static readonly int BUFFER_SIZE;
 		
@@ -51,18 +51,11 @@ namespace Lucene.Net.Store
 			currentBufferIndex = - 1;
 			currentBuffer = null;
 		}
-
-        // TODO: revisit Close() for 3.0
-        //public override void Dispose()
-        //{
-        //    // nothing to do here
-        //}
-
-		public override void  Close()
-		{
-			//Dispose();
-            // nothing to do here
-		}
+        
+        protected override void Dispose(bool disposing)
+        {
+            // do nothing
+        }
 		
 		public override long Length()
 		{

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SimpleFSDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SimpleFSDirectory.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SimpleFSDirectory.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SimpleFSDirectory.cs
Wed Jan 25 07:01:45 2012
@@ -27,7 +27,7 @@ namespace Lucene.Net.Store
 	/// read from the same file.  It's usually better to use
 	/// <see cref="NIOFSDirectory" /> or <see cref="MMapDirectory" /> instead. 
 	/// </summary>
-	public class SimpleFSDirectory:FSDirectory
+	public class SimpleFSDirectory : FSDirectory
 	{
         /// <summary>Create a new SimpleFSDirectory for the named location.
         /// 
@@ -82,7 +82,7 @@ namespace Lucene.Net.Store
 		    throw e;
 		}
 		
-		protected internal class SimpleFSIndexInput:BufferedIndexInput, System.ICloneable
+		protected internal class SimpleFSIndexInput : BufferedIndexInput
 		{
 			// TODO: This is a bad way to handle memory and disposing
 			protected internal class Descriptor : System.IO.BinaryReader
@@ -123,6 +123,7 @@ namespace Lucene.Net.Store
 			
 			protected internal Descriptor file;
 			internal bool isClone;
+		    private bool isDisposed;
 			//  LUCENE-1566 - maximum read length on a 32bit JVM to prevent incorrect OOM 
 			protected internal int chunkSize;
 
@@ -179,15 +180,24 @@ namespace Lucene.Net.Store
 					}
 				}
 			}
-			
-			public override void  Close()
-			{
-				// only close the file if this is not a clone
-				if (!isClone)
-					file.Close();
-			}
-			
-			public override void  SeekInternal(long position)
+
+            protected override void Dispose(bool disposing)
+            {
+                if (isDisposed) return;
+                if (disposing)
+                {
+                    // only close the file if this is not a clone
+                    if (!isClone && file != null)
+                    {
+                        file.Close();
+                        file = null;
+                    }
+                }
+
+                isDisposed = true;
+            }
+
+		    public override void  SeekInternal(long position)
 			{
 			}
 			

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CloseableThreadLocalProfiler.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CloseableThreadLocalProfiler.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CloseableThreadLocalProfiler.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CloseableThreadLocalProfiler.cs
Wed Jan 25 07:01:45 2012
@@ -7,15 +7,15 @@ namespace Lucene.Net.Support
     /// </summary>
     public class CloseableThreadLocalProfiler
     {
-        public static bool _EnableCloseableThreadLocalProfiler = false;
+        private static bool _enableCloseableThreadLocalProfiler = false;
         public static System.Collections.Generic.List<WeakReference> Instances = new
System.Collections.Generic.List<WeakReference>();
 
         public static bool EnableCloseableThreadLocalProfiler
         {
-            get { return _EnableCloseableThreadLocalProfiler; }
+            get { return _enableCloseableThreadLocalProfiler; }
             set
             {
-                _EnableCloseableThreadLocalProfiler = value;
+                _enableCloseableThreadLocalProfiler = value;
                 lock (Instances)
                     Instances.Clear();
             }

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/contrib/Highlighter/HighlighterTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/contrib/Highlighter/HighlighterTest.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/contrib/Highlighter/HighlighterTest.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/contrib/Highlighter/HighlighterTest.cs
Wed Jan 25 07:01:45 2012
@@ -495,7 +495,7 @@ namespace Lucene.Net.Search.Highlight
 		{
 			DoSearching("meat");
 			Highlighter highlighter = new Highlighter(this, new QueryScorer(query));
-			highlighter.SetMaxDocBytesToAnalyze(30);
+			highlighter.SetMaxDocCharsToAnalyze(30);
 			TokenStream tokenStream = analyzer.TokenStream(FIELD_NAME, new System.IO.StringReader(texts[0]));
 			highlighter.GetBestFragment(tokenStream, texts[0]);
 			Assert.IsTrue(numHighlights == 0, "Setting MaxDocBytesToAnalyze should have prevented
" + "us from finding matches for this record: " + numHighlights + " found");
@@ -521,16 +521,16 @@ namespace Lucene.Net.Search.Highlight
 				sb.Append(stopWords[0]);
 			}
 			
-			hg.SetMaxDocBytesToAnalyze(100);
+			hg.SetMaxDocCharsToAnalyze(100);
 			match = hg.GetBestFragment(new StandardAnalyzer(stopWords), "data", sb.ToString());
-			Assert.IsTrue(match.Length < hg.GetMaxDocBytesToAnalyze(), "Matched text should be
no more than 100 chars in length ");
+			Assert.IsTrue(match.Length < hg.GetMaxDocCharsToAnalyze(), "Matched text should be
no more than 100 chars in length ");
 			
 			//add another tokenized word to the overrall length - but set way beyond 
 			//the length of text under consideration (after a large slug of stop words + whitespace)
 			sb.Append(" ");
 			sb.Append(goodWord);
 			match = hg.GetBestFragment(new StandardAnalyzer(stopWords), "data", sb.ToString());
-			Assert.IsTrue(match.Length < hg.GetMaxDocBytesToAnalyze(), "Matched text should be
no more than 100 chars in length ");
+			Assert.IsTrue(match.Length < hg.GetMaxDocCharsToAnalyze(), "Matched text should be
no more than 100 chars in length ");
 		}
 		
 		

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestCharFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestCharFilter.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestCharFilter.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestCharFilter.cs
Wed Jan 25 07:01:45 2012
@@ -62,8 +62,8 @@ namespace Lucene.Net.Analysis
 			protected internal CharFilter1(CharStream in_Renamed):base(in_Renamed)
 			{
 			}
-			
-			public /*protected internal*/ override int Correct(int currentOff)
+
+		    protected internal override int Correct(int currentOff)
 			{
 				return currentOff + 1;
 			}
@@ -75,8 +75,8 @@ namespace Lucene.Net.Analysis
 			protected internal CharFilter2(CharStream in_Renamed):base(in_Renamed)
 			{
 			}
-			
-			public /*protected internal*/ override int Correct(int currentOff)
+
+		    protected internal override int Correct(int currentOff)
 			{
 				return currentOff + 2;
 			}

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/MockIndexInput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/MockIndexInput.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/MockIndexInput.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/MockIndexInput.cs
Wed Jan 25 07:01:45 2012
@@ -54,11 +54,11 @@ namespace Lucene.Net.Index
 			}
 			pointer += len;
 		}
-		
-		public override void  Close()
-		{
-			// ignore
-		}
+
+        protected override void Dispose(bool disposing)
+        {
+            //ignore
+        }
 		
 		public override void  SeekInternal(long pos)
 		{

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestFieldsReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestFieldsReader.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestFieldsReader.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestFieldsReader.cs
Wed Jan 25 07:01:45 2012
@@ -356,7 +356,7 @@ namespace Lucene.Net.Index
 		
 		public class FaultyFSDirectory:Directory
 		{
-			
+		    private bool isDisposed;
 			internal FSDirectory fsDir;
 			public FaultyFSDirectory(System.IO.DirectoryInfo dir)
 			{
@@ -395,14 +395,21 @@ namespace Lucene.Net.Index
 			{
 				return fsDir.CreateOutput(name);
 			}
-			public override void  Close()
-			{
-				fsDir.Close();
-			}
 
-            public override void Dispose()
+            protected override void Dispose(bool disposing)
             {
-                this.Close();
+                if (isDisposed) return;
+
+                if (disposing)
+                {
+                    if (fsDir != null)
+                    {
+                        fsDir.Close();
+                    }
+                }
+
+                fsDir = null;
+                isDisposed = true;
             }
 		}
 		
@@ -410,6 +417,7 @@ namespace Lucene.Net.Index
 		{
 			internal IndexInput delegate_Renamed;
 			internal static bool doFail;
+		    private bool isDisposed;
 			internal int count;
 			internal FaultyIndexInput(IndexInput delegate_Renamed)
 			{
@@ -427,19 +435,33 @@ namespace Lucene.Net.Index
 				SimOutage();
 				delegate_Renamed.ReadBytes(b, offset, length);
 			}
+
 			public override void  SeekInternal(long pos)
 			{
 				//simOutage();
 				delegate_Renamed.Seek(pos);
 			}
+
 			public override long Length()
 			{
 				return delegate_Renamed.Length();
 			}
-			public override void  Close()
-			{
-				delegate_Renamed.Close();
-			}
+
+            protected override void Dispose(bool disposing)
+            {
+                if (isDisposed) return;
+                if (disposing)
+                {
+                    if (delegate_Renamed != null)
+                    {
+                        delegate_Renamed.Close();
+                    }
+                }
+
+                delegate_Renamed = null;
+                isDisposed = true;
+            }
+
 			public override System.Object Clone()
 			{
 				return new FaultyIndexInput((IndexInput) delegate_Renamed.Clone());

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestLazyProxSkipping.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestLazyProxSkipping.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestLazyProxSkipping.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestLazyProxSkipping.cs
Wed Jan 25 07:01:45 2012
@@ -201,6 +201,7 @@ namespace Lucene.Net.Index
 				
 			}
 			private IndexInput input;
+		    private bool isDisposed;
 			
 			
 			internal SeeksCountingStream(TestLazyProxSkipping enclosingInstance, IndexInput input)
@@ -218,11 +219,17 @@ namespace Lucene.Net.Index
 			{
 				this.input.ReadBytes(b, offset, len);
 			}
-			
-			public override void  Close()
-			{
-				this.input.Close();
-			}
+
+            protected override void Dispose(bool disposing)
+            {
+                if (isDisposed) return;
+
+                if (disposing)
+                {
+                    this.input.Close();
+                }
+                isDisposed = true;
+            }
 			
 			public override long GetFilePointer()
 			{

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestMultiLevelSkipList.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestMultiLevelSkipList.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestMultiLevelSkipList.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestMultiLevelSkipList.cs
Wed Jan 25 07:01:45 2012
@@ -146,6 +146,7 @@ namespace Lucene.Net.Index
 				
 			}
 			private IndexInput input;
+		    private bool isDisposed;
 			
 			internal CountingStream(TestMultiLevelSkipList enclosingInstance, IndexInput input)
 			{
@@ -164,11 +165,17 @@ namespace Lucene.Net.Index
 				Enclosing_Instance.counter += len;
 				this.input.ReadBytes(b, offset, len);
 			}
-			
-			public override void  Close()
-			{
-				this.input.Close();
-			}
+
+            protected override void Dispose(bool disposing)
+            {
+                if (isDisposed) return;
+
+                if (disposing)
+                {
+                    this.input.Close();
+                }
+                isDisposed = true;
+            }
 			
 			public override long GetFilePointer()
 			{

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestPayloads.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestPayloads.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestPayloads.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestPayloads.cs Wed
Jan 25 07:01:45 2012
@@ -640,11 +640,12 @@ namespace Lucene.Net.Index
 				payloadAtt.SetPayload(new Payload(payload));
 				return true;
 			}
-			
-			public override void  Close()
-			{
-				pool.Release(payload);
-			}
+
+            protected override void Dispose(bool disposing)
+            {
+                pool.Release(payload);
+                base.Dispose(disposing);
+            }
 		}
 		
 		internal class ByteArrayPool

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFieldCacheRangeFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFieldCacheRangeFilter.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFieldCacheRangeFilter.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFieldCacheRangeFilter.cs
Wed Jan 25 07:01:45 2012
@@ -574,23 +574,23 @@ namespace Lucene.Net.Search
     Query q = new TermQuery(new Term("body","body"));
 
     FieldCacheRangeFilter<sbyte?> fcrf;
-    result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", -20, 20, T,
T), 100).scoreDocs;
+    result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", -20, 20, T,
T), 100).ScoreDocs;
     Assert.False(fcrf.GetDocIdSet(reader.GetSequentialSubReaders()[0]).IsCacheable(), "DocIdSet
must be not cacheable");
     Assert.AreEqual(40, result.Length, "find all");
 
-    result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", 0, 20, T, T),
100).scoreDocs;
+    result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", 0, 20, T, T),
100).ScoreDocs;
     Assert.False(fcrf.GetDocIdSet(reader.GetSequentialSubReaders()[0]).IsCacheable(), "DocIdSet
must be not cacheable");
     Assert.AreEqual( 20, result.Length, "find all");
 
-            result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", -20,
0, T, T), 100).scoreDocs;
+            result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", -20,
0, T, T), 100).ScoreDocs;
     Assert.False(fcrf.GetDocIdSet(reader.GetSequentialSubReaders()[0]).IsCacheable(), "DocIdSet
must be not cacheable");
     Assert.AreEqual( 20, result.Length, "find all");
 
-    result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", 10, 20, T,
T), 100).scoreDocs;
+    result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", 10, 20, T,
T), 100).ScoreDocs;
     Assert.True(fcrf.GetDocIdSet(reader.GetSequentialSubReaders()[0]).IsCacheable(), "DocIdSet
must be not cacheable");
     Assert.AreEqual( 11, result.Length, "find all");
 
-    result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", -20, -10, T,
T), 100).scoreDocs;
+    result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", -20, -10, T,
T), 100).ScoreDocs;
     Assert.True(fcrf.GetDocIdSet(reader.GetSequentialSubReaders()[0]).IsCacheable(), "DocIdSet
must be not cacheable");
     Assert.AreEqual( 11, result.Length, "find all");
   }

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFuzzyQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFuzzyQuery.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFuzzyQuery.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFuzzyQuery.cs
Wed Jan 25 07:01:45 2012
@@ -85,7 +85,7 @@ namespace Lucene.Net.Search
 
             // test scoring
             query = new FuzzyQuery(new Term("field", "bbbbb"), FuzzyQuery.defaultMinSimilarity,
0);
-            hits = searcher.Search(query, null, 1000).scoreDocs;
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
             Assert.AreEqual(3, hits.Length, "3 documents should match");
             List<String> order = new List<string>(new[] {"bbbbb", "abbbb", "aabbb"});
             for (int i = 0; i < hits.Length; i++)
@@ -102,7 +102,7 @@ namespace Lucene.Net.Search
                 BooleanQuery.SetMaxClauseCount(2);
                 // This query would normally return 3 documents, because 3 terms match (see
above):
                 query = new FuzzyQuery(new Term("field", "bbbbb"), FuzzyQuery.defaultMinSimilarity,
0);
-                hits = searcher.Search(query, null, 1000).scoreDocs;
+                hits = searcher.Search(query, null, 1000).ScoreDocs;
                 Assert.AreEqual(2, hits.Length, "only 2 documents should match");
                 order = new List<string>(new[] {"bbbbb", "abbbb"});
                 for (int i = 0; i < hits.Length; i++)

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestTermRangeFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestTermRangeFilter.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestTermRangeFilter.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestTermRangeFilter.cs
Wed Jan 25 07:01:45 2012
@@ -301,47 +301,47 @@ namespace Lucene.Net.Search
 			
 			// test extremes, bounded on both ends
 
-            int numHits = search.Search(q, new TermRangeFilter("rand", minRP, maxRP, T, T,
c), 1000).totalHits;
+            int numHits = search.Search(q, new TermRangeFilter("rand", minRP, maxRP, T, T,
c), 1000).TotalHits;
 			Assert.AreEqual(numDocs, numHits, "find all");
 
-            numHits = search.Search(q, new TermRangeFilter("rand", minRP, maxRP, T, F, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", minRP, maxRP, T, F, c),
1000).TotalHits;
 			Assert.AreEqual(numDocs - 1, numHits, "all but biggest");
 
-            numHits = search.Search(q, new TermRangeFilter("rand", minRP, maxRP, F, T, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", minRP, maxRP, F, T, c),
1000).TotalHits;
 			Assert.AreEqual(numDocs - 1, numHits, "all but smallest");
 
-            numHits = search.Search(q, new TermRangeFilter("rand", minRP, maxRP, F, F, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", minRP, maxRP, F, F, c),
1000).TotalHits;
 			Assert.AreEqual(numDocs - 2, numHits, "all but extremes");
 			
 			// unbounded
 
-            numHits = search.Search(q, new TermRangeFilter("rand", minRP, null, T, F, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", minRP, null, T, F, c),
1000).TotalHits;
 			Assert.AreEqual(numDocs, numHits, "smallest and up");
 
-            numHits = search.Search(q, new TermRangeFilter("rand", null, maxRP, F, T, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", null, maxRP, F, T, c),
1000).TotalHits;
 			Assert.AreEqual(numDocs, numHits, "biggest and down");
 
-            numHits = search.Search(q, new TermRangeFilter("rand", minRP, null, F, F, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", minRP, null, F, F, c),
1000).TotalHits;
 			Assert.AreEqual(numDocs - 1, numHits, "not smallest, but up");
 
-            numHits = search.Search(q, new TermRangeFilter("rand", null, maxRP, F, F, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", null, maxRP, F, F, c),
1000).TotalHits;
 			Assert.AreEqual(numDocs - 1, numHits, "not biggest, but down");
 			
 			// very small sets
 
-            numHits = search.Search(q, new TermRangeFilter("rand", minRP, minRP, F, F, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", minRP, minRP, F, F, c),
1000).TotalHits;
 			Assert.AreEqual(0, numHits, "min,min,F,F");
-            numHits = search.Search(q, new TermRangeFilter("rand", maxRP, maxRP, F, F, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", maxRP, maxRP, F, F, c),
1000).TotalHits;
 			Assert.AreEqual(0, numHits, "max,max,F,F");
 
-            numHits = search.Search(q, new TermRangeFilter("rand", minRP, minRP, T, T, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", minRP, minRP, T, T, c),
1000).TotalHits;
 			Assert.AreEqual(1, numHits, "min,min,T,T");
-            numHits = search.Search(q, new TermRangeFilter("rand", null, minRP, F, T, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", null, minRP, F, T, c),
1000).TotalHits;
 			Assert.AreEqual(1, numHits, "nul,min,F,T");
 
-            numHits = search.Search(q, new TermRangeFilter("rand", maxRP, maxRP, T, T, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", maxRP, maxRP, T, T, c),
1000).TotalHits;
 			Assert.AreEqual(1, numHits, "max,max,T,T");
-            numHits = search.Search(q, new TermRangeFilter("rand", maxRP, null, T, F, c),
1000).totalHits;
+            numHits = search.Search(q, new TermRangeFilter("rand", maxRP, null, T, F, c),
1000).TotalHits;
 			Assert.AreEqual(1, numHits, "max,nul,T,T");
 		}
 		

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/MockRAMDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/MockRAMDirectory.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/MockRAMDirectory.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/MockRAMDirectory.cs
Wed Jan 25 07:01:45 2012
@@ -276,7 +276,7 @@ namespace Lucene.Net.Store
                 {
                     if (existing != null)
                     {
-                        sizeInBytes -= existing.sizeInBytes_ForNUnit;
+                        _sizeInBytes -= existing.sizeInBytes_ForNUnit;
                         existing.directory_ForNUnit = null;
                     }
 
@@ -340,7 +340,7 @@ namespace Lucene.Net.Store
             }
         }
 
-        public override void Close()
+        protected override void Dispose(bool disposing)
         {
             lock (this)
             {
@@ -356,6 +356,8 @@ namespace Lucene.Net.Store
                     throw new System.SystemException("MockRAMDirectory: cannot close: there
are still open files: " + openFiles);
                 }
             }
+
+            base.Dispose(disposing);
         }
 
         /**

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/MockRAMInputStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/MockRAMInputStream.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/MockRAMInputStream.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/MockRAMInputStream.cs
Wed Jan 25 07:01:45 2012
@@ -31,6 +31,7 @@ namespace Lucene.Net.Store
 		private MockRAMDirectory dir;
 		private System.String name;
 		private bool isClone;
+	    private bool isDisposed;
 		
 		/// <summary>Construct an empty output buffer. </summary>
 		/// <throws>  IOException  </throws>
@@ -39,34 +40,38 @@ namespace Lucene.Net.Store
 			this.name = name;
 			this.dir = dir;
 		}
-		
-		public override void  Close()
-		{
-			base.Close();
-			// Pending resolution on LUCENE-686 we may want to
-			// remove the conditional check so we also track that
-			// all clones get closed:
-			if (!isClone)
-			{
-				lock (dir)
-				{
-					// Could be null when MockRAMDirectory.crash() was called
-					if (dir.openFiles[name] != null)
-					{
-						System.Int32 v = dir.openFiles[name];
-						if (v == 1)
-						{
-							dir.openFiles.Remove(name);
-						}
-						else
-						{
-							v = v - 1;
-							dir.openFiles[name] = v;
-						}
-					}
-				}
-			}
-		}
+
+        protected override void Dispose(bool disposing)
+        {
+            if (isDisposed) return;
+
+            // Pending resolution on LUCENE-686 we may want to
+            // remove the conditional check so we also track that
+            // all clones get closed:
+            if (disposing && !isClone)
+            {
+                lock (dir)
+                {
+                    // Could be null when MockRAMDirectory.crash() was called
+                    if (dir.openFiles[name] != null)
+                    {
+                        System.Int32 v = dir.openFiles[name];
+                        if (v == 1)
+                        {
+                            dir.openFiles.Remove(name);
+                        }
+                        else
+                        {
+                            v = v - 1;
+                            dir.openFiles[name] = v;
+                        }
+                    }
+                }
+            }
+
+            isDisposed = true;
+            base.Dispose(disposing);
+        }
 		
 		public override System.Object Clone()
 		{

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/TestBufferedIndexInput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/TestBufferedIndexInput.cs?rev=1235645&r1=1235644&r2=1235645&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/TestBufferedIndexInput.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Store/TestBufferedIndexInput.cs
Wed Jan 25 07:01:45 2012
@@ -271,10 +271,11 @@ namespace Lucene.Net.Store
 			{
 				this.pos = pos;
 			}
-			
-			public override void  Close()
-			{
-			}
+
+            protected override void Dispose(bool disposing)
+            {
+                // Do nothing
+            }
 			
 			public override long Length()
 			{
@@ -342,6 +343,7 @@ namespace Lucene.Net.Store
 			internal System.Random rand;
 			
 			private Directory dir;
+		    private bool isDisposed;
 			
 			public MockFSDirectory(System.IO.DirectoryInfo path, System.Random rand)
 			{
@@ -382,18 +384,21 @@ namespace Lucene.Net.Store
 			{
 				return dir.CreateOutput(name);
 			}
-			
-			public override void  Close()
-			{
-				dir.Close();
-			}
 
-            /// <summary>
-            /// .NET
-            /// </summary>
-            public override void Dispose()
+            protected override void Dispose(bool disposing)
             {
-                Close();
+                if (isDisposed) return;
+
+                if (disposing)
+                {
+                    if (dir != null)
+                    {
+                        dir.Close();
+                    }
+                }
+
+                dir = null;
+                isDisposed = true;
             }
 			
 			public override void  DeleteFile(System.String name)



Mime
View raw message