BUG: Lucene.Net.Tests.Common.Util.BufferedCharFilter: Changed to only consider 
the IsReady property for CharFilter-derived types. All other TextReaders are 
assumed to be ready.


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

Branch: refs/heads/master
Commit: 8002783aa03a45e3a5c698dedf9590eb6eeab5c3
Parents: 00b9566
Author: Shad Storhaug <[email protected]>
Authored: Fri Apr 28 16:56:48 2017 +0700
Committer: Shad Storhaug <[email protected]>
Committed: Mon May 1 04:45:05 2017 +0700

----------------------------------------------------------------------
 .../Analysis/Util/BufferedCharFilter.cs         | 18 ++++++++++++-----
 .../Analysis/Core/TestBugInSomething.cs         |  4 ++--
 .../Analysis/Core/TestRandomChains.cs           |  4 ++--
 .../Analysis/Util/TestBufferedCharFilter.cs     | 21 ++++++++++++++------
 .../Support/TestApiConsistency.cs               |  2 +-
 src/Lucene.Net/Analysis/CharFilter.cs           | 14 ++++++-------
 6 files changed, 40 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8002783a/src/Lucene.Net.Analysis.Common/Analysis/Util/BufferedCharFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/BufferedCharFilter.cs 
b/src/Lucene.Net.Analysis.Common/Analysis/Util/BufferedCharFilter.cs
index c475772..0a9b5d9 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/BufferedCharFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/BufferedCharFilter.cs
@@ -323,7 +323,10 @@ namespace Lucene.Net.Analysis.Util
                      * done, or if we've already got some bytes and reading 
from the
                      * underlying stream would block.
                      */
-                    if (outstanding == 0 /*|| (outstanding < length && 
[email protected]())*/) {
+                    // LUCENENET specific: only CharFilter derived types 
support IsReady
+                    var charFilter = @in as CharFilter;
+                    if (outstanding == 0 || (outstanding < length) && 
charFilter != null && !charFilter.IsReady)
+                    {
                         break;
                     }
 
@@ -488,12 +491,17 @@ namespace Lucene.Net.Analysis.Util
         /// <c>true</c> if this reader will not block when <see cref="Read"/> 
is
         /// called, <c>false</c> if unknown or blocking will occur.
         /// </returns>
-        public override bool Ready()
+        public override bool IsReady
         {
-            lock (m_lock)
+            get
             {
-                EnsureOpen();
-                return ((end - pos) > 0) /*|| in.ready()*/;
+                lock (m_lock)
+                {
+                    EnsureOpen();
+                    // LUCENENET specific: only CharFilter derived types 
support IsReady
+                    var charFilter = @in as CharFilter;
+                    return ((end - pos) > 0) || (charFilter != null && 
charFilter.IsReady);
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8002783a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestBugInSomething.cs
----------------------------------------------------------------------
diff --git 
a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestBugInSomething.cs 
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestBugInSomething.cs
index 5bea6c3..db54452 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestBugInSomething.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestBugInSomething.cs
@@ -118,9 +118,9 @@ namespace Lucene.Net.Analysis.Core
             //    throw new System.NotSupportedException("Read(CharBuffer)");
             //}
 
-            public override bool Ready()
+            public override bool IsReady
             {
-                throw new System.NotSupportedException("Ready()");
+                get { throw new System.NotSupportedException("Ready()"); }
             }
 
             public override void Reset()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8002783a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestRandomChains.cs
----------------------------------------------------------------------
diff --git 
a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestRandomChains.cs 
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestRandomChains.cs
index 8654ffa..d1a13a7 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestRandomChains.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestRandomChains.cs
@@ -1120,9 +1120,9 @@ namespace Lucene.Net.Analysis.Core
                 }
             }
 
-            public override bool Ready()
+            public override bool IsReady
             {
-                return Input.Ready();
+                get { return Input.IsReady; }
             }
 
             public override void Reset()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8002783a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestBufferedCharFilter.cs
----------------------------------------------------------------------
diff --git 
a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestBufferedCharFilter.cs 
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestBufferedCharFilter.cs
index 887a7df..eccc949 100644
--- 
a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestBufferedCharFilter.cs
+++ 
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestBufferedCharFilter.cs
@@ -254,13 +254,17 @@ namespace Lucene.Net.Analysis.Util
             assertTrue(new BufferedCharFilter(new StringReader(new string(new 
char[5], 1, 0)), 2).Read() == -1);
         }
 
-        private class ReaderAnonymousInnerClassHelper : TextReader
+        private class ReaderAnonymousInnerClassHelper : CharFilter
         {
             private const int SIZE = 2;
             private int size = SIZE, pos = 0;
 
             private readonly char[] contents = new char[SIZE];
 
+            public ReaderAnonymousInnerClassHelper()
+                : base(null)
+            { }
+
             public override int Read()
             {
                 if (pos >= size)
@@ -285,14 +289,19 @@ namespace Lucene.Net.Analysis.Util
                 return size - pos > 0;
             }
 
-#if !NETSTANDARD
-            public override void Close()
+//#if !NETSTANDARD
+//            public override void Close()
+//            {
+//            }
+//#endif
+
+            protected override void Dispose(bool disposing)
             {
             }
-#endif
 
-            protected override void Dispose(bool disposing)
+            protected override int Correct(int currentOff)
             {
+                throw new NotImplementedException();
             }
         }
 
@@ -684,7 +693,7 @@ namespace Lucene.Net.Analysis.Util
             try
             {
                 br = new BufferedCharFilter(new StringReader(testString));
-                assertTrue("ready returned false", br.Ready());
+                assertTrue("IsReady returned false", br.IsReady);
             }
             catch (IOException e)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8002783a/src/Lucene.Net.Tests/Support/TestApiConsistency.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Support/TestApiConsistency.cs 
b/src/Lucene.Net.Tests/Support/TestApiConsistency.cs
index 0143e5a..c662c07 100644
--- a/src/Lucene.Net.Tests/Support/TestApiConsistency.cs
+++ b/src/Lucene.Net.Tests/Support/TestApiConsistency.cs
@@ -42,7 +42,7 @@ namespace Lucene.Net
         [TestCase(typeof(Lucene.Net.Analysis.Analyzer))]
         public override void TestPrivateFieldNames(Type typeFromTargetAssembly)
         {
-            base.TestPrivateFieldNames(typeFromTargetAssembly, 
@"^Lucene\.Net\.Support\.(?:LurchTable|HashUtilities|ThreadClass\.This|C5)");
+            base.TestPrivateFieldNames(typeFromTargetAssembly, 
@"^Lucene\.Net\.Support\.(?:LurchTable|HashUtilities|Threading\.ThreadClass\.This|C5)");
         }
 
         [Test, LuceneNetSpecific]

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8002783a/src/Lucene.Net/Analysis/CharFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Analysis/CharFilter.cs 
b/src/Lucene.Net/Analysis/CharFilter.cs
index e253a1f..4a8c53a 100644
--- a/src/Lucene.Net/Analysis/CharFilter.cs
+++ b/src/Lucene.Net/Analysis/CharFilter.cs
@@ -92,7 +92,7 @@ namespace Lucene.Net.Analysis
         /// <summary>
         /// Skips characters. This method will block until some characters are 
available, an I/O error occurs, or the end of the stream is reached.
         /// 
-        /// LUCENENET specific. Moved here from the Java Reader class so it 
can be overridden to provide reader buffering.
+        /// LUCENENET specific. Moved here from the Reader class (in Java) so 
it can be overridden to provide reader buffering.
         /// </summary>
         /// <param name="n">The number of characters to skip</param>
         /// <returns>The number of characters actually skipped</returns>
@@ -102,7 +102,7 @@ namespace Lucene.Net.Analysis
         }
 
         /// <summary>
-        /// LUCENENET specific. Moved here from the Java Reader class so it 
can be overridden to provide reader buffering.
+        /// LUCENENET specific. Moved here from the Reader class (in Java) so 
it can be overridden to provide reader buffering.
         /// </summary>
         /// <returns></returns>
         public virtual void Reset()
@@ -116,18 +116,18 @@ namespace Lucene.Net.Analysis
         /// True if the next <see cref="TextReader.Read()"/> is guaranteed not 
to block for input, false otherwise. Note 
         /// that returning false does not guarantee that the next read will 
block.
         /// <para/>
-        /// LUCENENET specific. Moved here from the Java Reader class so it 
can be overridden to provide reader buffering.
+        /// LUCENENET specific. Moved here from the Reader class (in Java) so 
it can be overridden to provide reader buffering.
         /// </summary>
-        public virtual bool Ready()
+        public virtual bool IsReady
         {
-            return false;
+            get { return false; }
         }
 
         /// <summary>
         /// Tells whether this stream supports the <see cref="Mark(int)"/> 
operation. The default implementation always 
         /// returns false. Subclasses should override this method.
         /// <para/>
-        /// LUCENENET specific. Moved here from the Java Reader class so it 
can be overridden to provide reader buffering.
+        /// LUCENENET specific. Moved here from the Reader class (in Java) so 
it can be overridden to provide reader buffering.
         /// </summary>
         /// <returns>true if and only if this stream supports the mark 
operation.</returns>
         public virtual bool IsMarkSupported
@@ -139,7 +139,7 @@ namespace Lucene.Net.Analysis
         /// Marks the present position in the stream. Subsequent calls to <see 
cref="Reset"/> will attempt to 
         /// reposition the stream to this point. Not all character-input 
streams support the <see cref="Mark(int)"/> operation.
         /// <para/>
-        /// LUCENENET specific. Moved here from the Java Reader class so it 
can be overridden to provide reader buffering.
+        /// LUCENENET specific. Moved here from the Reader class (in Java) so 
it can be overridden to provide reader buffering.
         /// </summary>
         /// <param name="readAheadLimit">Limit on the number of characters 
that may be read while still preserving the mark. After 
         /// reading this many characters, attempting to reset the stream may 
fail.</param>

Reply via email to