lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [07/47] lucenenet git commit: Fixed several bugs that were causing the Codecs.SimpleText tests to fail.
Date Tue, 11 Oct 2016 18:34:52 GMT
Fixed several bugs that were causing the Codecs.SimpleText tests to fail.


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

Branch: refs/heads/master
Commit: 166ef1ee3b451b2e961c22b98e36a397b0926294
Parents: 2fa691b
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sat Oct 8 13:13:29 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sat Oct 8 17:15:41 2016 +0700

----------------------------------------------------------------------
 .../SimpleText/SimpleTextDocValuesReader.cs     | 77 ++++++++++----------
 .../SimpleText/SimpleTextDocValuesWriter.cs     | 60 ++++++++-------
 .../SimpleText/SimpleTextFieldInfosReader.cs    |  3 +-
 .../SimpleText/SimpleTextFieldInfosWriter.cs    | 19 ++---
 .../SimpleText/SimpleTextFieldsReader.cs        | 16 ++--
 .../SimpleText/SimpleTextSegmentInfoReader.cs   | 13 ++--
 .../SimpleText/SimpleTextStoredFieldsReader.cs  | 19 +++--
 .../SimpleText/SimpleTextTermVectorsReader.cs   | 11 +--
 .../SimpleText/SimpleTextTermVectorsWriter.cs   |  2 +-
 src/Lucene.Net.Core/Document/Document.cs        |  2 +-
 src/Lucene.Net.Core/Index/IndexWriter.cs        |  8 +-
 src/Lucene.Net.Core/Index/SegmentInfo.cs        |  2 +-
 .../Index/StandardDirectoryReader.cs            | 14 ++--
 .../Store/TrackingDirectoryWrapper.cs           |  3 +-
 .../Store/MockDirectoryWrapper.cs               | 17 +++--
 .../Store/MockIndexInputWrapper.cs              |  6 +-
 16 files changed, 146 insertions(+), 126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
index 7725777..da92bac 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
@@ -21,24 +21,27 @@ namespace Lucene.Net.Codecs.SimpleText
     using System.Diagnostics;
     using System.Collections.Generic;
     using System.ComponentModel;
+    using System.Globalization;
+    using System.Text;
     using Support;
 
-	using BinaryDocValues = Index.BinaryDocValues;
-	using CorruptIndexException = Index.CorruptIndexException;
-	using DocValues = Index.DocValues;
-	using FieldInfo = Index.FieldInfo;
-	using DocValuesType = Index.FieldInfo.DocValuesType_e;
-	using IndexFileNames = Index.IndexFileNames;
-	using NumericDocValues = Index.NumericDocValues;
-	using SegmentReadState = Index.SegmentReadState;
-	using SortedDocValues = Index.SortedDocValues;
-	using SortedSetDocValues = Index.SortedSetDocValues;
-	using BufferedChecksumIndexInput = Store.BufferedChecksumIndexInput;
-	using ChecksumIndexInput = Store.ChecksumIndexInput;
-	using IndexInput = Store.IndexInput;
-	using Bits = Util.Bits;
-	using BytesRef = Util.BytesRef;
-	using StringHelper = Util.StringHelper;
+    using BinaryDocValues = Index.BinaryDocValues;
+    using CorruptIndexException = Index.CorruptIndexException;
+    using DocValues = Index.DocValues;
+    using FieldInfo = Index.FieldInfo;
+    using DocValuesType = Index.FieldInfo.DocValuesType_e;
+    using IndexFileNames = Index.IndexFileNames;
+    using NumericDocValues = Index.NumericDocValues;
+    using SegmentReadState = Index.SegmentReadState;
+    using SortedDocValues = Index.SortedDocValues;
+    using SortedSetDocValues = Index.SortedSetDocValues;
+    using BufferedChecksumIndexInput = Store.BufferedChecksumIndexInput;
+    using ChecksumIndexInput = Store.ChecksumIndexInput;
+    using IndexInput = Store.IndexInput;
+    using Bits = Util.Bits;
+    using BytesRef = Util.BytesRef;
+    using StringHelper = Util.StringHelper;
+    using System.Numerics;
 
     public class SimpleTextDocValuesReader : DocValuesProducer
     {
@@ -205,7 +208,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
         protected override void Dispose(bool disposing)
         {
-            if (disposing) return;
+            if (!disposing) return;
 
             DATA.Dispose();
         }
@@ -242,7 +245,7 @@ namespace Lucene.Net.Codecs.SimpleText
         /// <summary> Used only in ctor: </summary>
         private string StripPrefix(BytesRef prefix)
         {
-            return SCRATCH.Bytes.SubList(SCRATCH.Offset + prefix.Length, SCRATCH.Length -
prefix.Length).ToString();
+            return Encoding.UTF8.GetString(SCRATCH.Bytes, SCRATCH.Offset + prefix.Length,
SCRATCH.Length - prefix.Length);
         }
 
         public override long RamBytesUsed()
@@ -324,8 +327,8 @@ namespace Lucene.Net.Codecs.SimpleText
                 int len;
                 try
                 {
-                    len = int.Parse(_scratch.Bytes.SubList(_scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
-                                _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString());
+                    len = int.Parse(Encoding.UTF8.GetString(_scratch.Bytes, _scratch.Offset
+ SimpleTextDocValuesWriter.LENGTH.Length,
+                        _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length), NumberStyles.Number,
CultureInfo.InvariantCulture);
                 }
                 catch (FormatException ex)
                 {
@@ -380,7 +383,8 @@ namespace Lucene.Net.Codecs.SimpleText
                 SimpleTextUtil.ReadLine(_input, _scratch);
                 try
                 {
-                    return int.Parse(Decimal.Parse(_scratch.Utf8ToString()).ToString(_ordDecoderFormat))
- 1;
+                    // LUCNENENET: .NET doesn't have a way to specify a pattern with integer,
but all of the standard ones are built in.
+                    return int.Parse(_scratch.Utf8ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture)
- 1;
                 }
                 catch (Exception pe)
                 {
@@ -403,11 +407,10 @@ namespace Lucene.Net.Codecs.SimpleText
                 int len;
                 try
                 {
-                    len =
-                        int.Parse(
-                            Decimal.Parse(_scratch.Bytes.SubList(
-                                _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
-                                _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString()).ToString(_decoderFormat));
+                    // LUCNENENET: .NET doesn't have a way to specify a pattern with integer,
but all of the standard ones are built in.
+                    len = int.Parse(Encoding.UTF8.GetString(_scratch.Bytes, _scratch.Offset
+ SimpleTextDocValuesWriter.LENGTH.Length,
+                        _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length), NumberStyles.Integer,
CultureInfo.InvariantCulture);
+
                 }
                 catch (Exception pe)
                 {
@@ -488,11 +491,9 @@ namespace Lucene.Net.Codecs.SimpleText
                 int len;
                 try
                 {
-                    len =
-                        int.Parse(
-                            Decimal.Parse(_scratch.Bytes.SubList(
-                                _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
-                                _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString()).ToString(_decoderFormat));
+                    // LUCNENENET: .NET doesn't have a way to specify a pattern with integer,
but all of the standard ones are built in.
+                    len = int.Parse(Encoding.UTF8.GetString(_scratch.Bytes, _scratch.Offset
+ SimpleTextDocValuesWriter.LENGTH.Length,
+                        _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length), NumberStyles.Integer,
CultureInfo.InvariantCulture);
                 }
                 catch (Exception pe)
                 {
@@ -538,10 +539,12 @@ namespace Lucene.Net.Codecs.SimpleText
                 _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2)
* docId);
                 SimpleTextUtil.ReadLine(_input, _scratch);
 
-                long bd;
+                
+                decimal bd;
                 try
                 {
-                    bd = long.Parse(_scratch.Utf8ToString());
+                    // LUCNENENET: .NET doesn't have a way to specify a pattern with decimal,
but all of the standard ones are built in.
+                    bd = decimal.Parse(_scratch.Utf8ToString(), NumberStyles.Float, CultureInfo.InvariantCulture);
                 }
                 catch (FormatException ex)
                 {
@@ -549,7 +552,7 @@ namespace Lucene.Net.Codecs.SimpleText
                 }
 
                 SimpleTextUtil.ReadLine(_input, _scratch); // read the line telling us if
its real or not
-                return _field.MinValue + bd;
+                return (long)BigInteger.Add(new BigInteger(_field.MinValue), new BigInteger(bd));
             }
         }
 
@@ -582,9 +585,9 @@ namespace Lucene.Net.Codecs.SimpleText
                 int len;
                 try
                 {
-                    len = int.Parse(_scratch.Bytes.SubList(
-                                _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
-                                _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString());
+                    // LUCNENENET: .NET doesn't have a way to specify a pattern with integer,
but all of the standard ones are built in.
+                    len = int.Parse(Encoding.UTF8.GetString(_scratch.Bytes, _scratch.Offset
+ SimpleTextDocValuesWriter.LENGTH.Length,
+                        _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length), NumberStyles.Integer,
CultureInfo.InvariantCulture);
                 }
                 catch (FormatException ex)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
index e2bd264..f31947a 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
@@ -21,6 +21,8 @@ namespace Lucene.Net.Codecs.SimpleText
     using System;
     using System.Diagnostics;
     using System.Collections.Generic;
+    using System.Globalization;
+    using System.Numerics;
     using System.Text;
 
     using FieldInfo = Index.FieldInfo;
@@ -74,21 +76,21 @@ namespace Lucene.Net.Codecs.SimpleText
             foreach (var n in values)
             {
                 var v = n.GetValueOrDefault();
-                minValue = Math.Min(minValue, v); // Added .Value to account for long?
-                maxValue = Math.Max(maxValue, v); // Added .Value to account for long?
+                minValue = Math.Min(minValue, v);
+                maxValue = Math.Max(maxValue, v);
             }
 
             // write our minimum value to the .dat, all entries are deltas from that
             SimpleTextUtil.Write(data, MINVALUE);
-            SimpleTextUtil.Write(data, Convert.ToString(minValue), scratch);
+            SimpleTextUtil.Write(data, minValue.ToString(CultureInfo.InvariantCulture), scratch);
             SimpleTextUtil.WriteNewline(data);
 
             // build up our fixed-width "simple text packed ints" format
-            System.Numerics.BigInteger maxBig = maxValue;
-            System.Numerics.BigInteger minBig = minValue;
-            var diffBig = maxBig - minBig;
+            BigInteger maxBig = maxValue;
+            BigInteger minBig = minValue;
+            var diffBig = BigInteger.Subtract(maxBig, minBig);
 
-            var maxBytesPerValue = diffBig.ToString().Length;
+            var maxBytesPerValue = diffBig.ToString(CultureInfo.InvariantCulture).Length;
             var sb = new StringBuilder();
             for (var i = 0; i < maxBytesPerValue; i++)
                 sb.Append('0');
@@ -109,8 +111,8 @@ namespace Lucene.Net.Codecs.SimpleText
 
                 Debug.Assert(value >= minValue);
 
-                var delta = value - minValue;
-                string s = delta.ToString(patternString);
+                var delta = BigInteger.Subtract(value, minValue);
+                string s = delta.ToString(patternString, CultureInfo.InvariantCulture);
                 Debug.Assert(s.Length == patternString.Length);
                 SimpleTextUtil.Write(data, s, scratch);
                 SimpleTextUtil.WriteNewline(data);
@@ -138,18 +140,20 @@ namespace Lucene.Net.Codecs.SimpleText
 
             // write maxLength
             SimpleTextUtil.Write(data, MAXLENGTH);
-            SimpleTextUtil.Write(data, Convert.ToString(maxLength), scratch);
+            SimpleTextUtil.Write(data, maxLength.ToString(CultureInfo.InvariantCulture),
scratch);
             SimpleTextUtil.WriteNewline(data);
 
-            var maxBytesLength = Convert.ToString(maxLength).Length;
+            var maxBytesLength = maxLength.ToString(CultureInfo.InvariantCulture).Length;
             var sb = new StringBuilder();
             for (var i = 0; i < maxBytesLength; i++)
             {
                 sb.Append('0');
             }
             // write our pattern for encoding lengths
+            var patternString = sb.ToString();
+
             SimpleTextUtil.Write(data, PATTERN);
-            SimpleTextUtil.Write(data, sb.ToString(), scratch);
+            SimpleTextUtil.Write(data, patternString, scratch);
             SimpleTextUtil.WriteNewline(data);
             
            
@@ -158,7 +162,7 @@ namespace Lucene.Net.Codecs.SimpleText
             {
                 int length = value == null ? 0 : value.Length;
                 SimpleTextUtil.Write(data, LENGTH);
-                SimpleTextUtil.Write(data, length.ToString(sb.ToString()), scratch);
+                SimpleTextUtil.Write(data, length.ToString(patternString, CultureInfo.InvariantCulture),
scratch);
                 SimpleTextUtil.WriteNewline(data);
 
                 // write bytes -- don't use SimpleText.Write
@@ -198,15 +202,15 @@ namespace Lucene.Net.Codecs.SimpleText
 
             // write numValues
             SimpleTextUtil.Write(data, NUMVALUES);
-            SimpleTextUtil.Write(data, Convert.ToString(valueCount), scratch);
+            SimpleTextUtil.Write(data, valueCount.ToString(CultureInfo.InvariantCulture),
scratch);
             SimpleTextUtil.WriteNewline(data);
 
             // write maxLength
             SimpleTextUtil.Write(data, MAXLENGTH);
-            SimpleTextUtil.Write(data, Convert.ToString(maxLength), scratch);
+            SimpleTextUtil.Write(data, maxLength.ToString(CultureInfo.InvariantCulture),
scratch);
             SimpleTextUtil.WriteNewline(data);
 
-            int maxBytesLength = Convert.ToString(maxLength).Length;
+            int maxBytesLength = maxLength.ToString(CultureInfo.InvariantCulture).Length;
             var sb = new StringBuilder();
             for (int i = 0; i < maxBytesLength; i++)
             {
@@ -220,7 +224,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
             var encoderFormat = sb.ToString();
 
-            int maxOrdBytes = Convert.ToString(valueCount + 1L).Length;
+            int maxOrdBytes = (valueCount + 1L).ToString(CultureInfo.InvariantCulture).Length;
             sb.Length = 0;
             for (int i = 0; i < maxOrdBytes; i++)
             {
@@ -241,7 +245,7 @@ namespace Lucene.Net.Codecs.SimpleText
             {
                 // write length
                 SimpleTextUtil.Write(data, LENGTH);
-                SimpleTextUtil.Write(data, value.Length.ToString(encoderFormat), scratch);
+                SimpleTextUtil.Write(data, value.Length.ToString(encoderFormat, CultureInfo.InvariantCulture),
scratch);
                 SimpleTextUtil.WriteNewline(data);
 
                 // write bytes -- don't use SimpleText.Write
@@ -251,7 +255,7 @@ namespace Lucene.Net.Codecs.SimpleText
                 // pad to fit
                 for (int i = value.Length; i < maxLength; i++)
                 {
-                    data.WriteByte((byte)(sbyte) ' ');
+                    data.WriteByte((byte)' ');
                 }
                 SimpleTextUtil.WriteNewline(data);
                 valuesSeen++;
@@ -262,7 +266,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
             foreach (var ord in docToOrd)
             {
-                SimpleTextUtil.Write(data, (ord + 1).Value.ToString(ordEncoderFormat), scratch);
+                SimpleTextUtil.Write(data, (ord + 1).GetValueOrDefault().ToString(ordEncoderFormat,
CultureInfo.InvariantCulture), scratch);
                 SimpleTextUtil.WriteNewline(data);
             }
         }
@@ -284,15 +288,15 @@ namespace Lucene.Net.Codecs.SimpleText
 
             // write numValues
             SimpleTextUtil.Write(data, NUMVALUES);
-            SimpleTextUtil.Write(data, Convert.ToString(valueCount), scratch);
+            SimpleTextUtil.Write(data, valueCount.ToString(CultureInfo.InvariantCulture),
scratch);
             SimpleTextUtil.WriteNewline(data);
 
             // write maxLength
             SimpleTextUtil.Write(data, MAXLENGTH);
-            SimpleTextUtil.Write(data, Convert.ToString(maxLength), scratch);
+            SimpleTextUtil.Write(data, maxLength.ToString(CultureInfo.InvariantCulture),
scratch);
             SimpleTextUtil.WriteNewline(data);
 
-            int maxBytesLength = Convert.ToString(maxLength).Length;
+            int maxBytesLength = maxLength.ToString(CultureInfo.InvariantCulture).Length;
             var sb = new StringBuilder();
             for (int i = 0; i < maxBytesLength; i++)
             {
@@ -323,7 +327,7 @@ namespace Lucene.Net.Codecs.SimpleText
                     {
                         sb2.Append(",");
                     }
-                    sb2.Append(Convert.ToString(ord));
+                    sb2.Append(ord.GetValueOrDefault().ToString(CultureInfo.InvariantCulture));
                 }
                 maxOrdListLength = Math.Max(maxOrdListLength, sb2.Length);
             }
@@ -346,7 +350,7 @@ namespace Lucene.Net.Codecs.SimpleText
             {
                 // write length
                 SimpleTextUtil.Write(data, LENGTH);
-                SimpleTextUtil.Write(data, value.Length.ToString(encoderFormat), scratch);
+                SimpleTextUtil.Write(data, value.Length.ToString(encoderFormat, CultureInfo.InvariantCulture),
scratch);
                 SimpleTextUtil.WriteNewline(data);
 
                 // write bytes -- don't use SimpleText.Write
@@ -356,7 +360,7 @@ namespace Lucene.Net.Codecs.SimpleText
                 // pad to fit
                 for (var i = value.Length; i < maxLength; i++)
                 {
-                    data.WriteByte((byte)(sbyte) ' ');
+                    data.WriteByte((byte)' ');
                 }
                 SimpleTextUtil.WriteNewline(data);
                 valuesSeen++;
@@ -379,7 +383,7 @@ namespace Lucene.Net.Codecs.SimpleText
                     if (sb2.Length > 0)
                         sb2.Append(",");
                     
-                    sb2.Append(Convert.ToString(ord));
+                    sb2.Append(ord);
                 }
                 // now pad to fit: these are numbers so spaces work well. reader calls trim()
                 var numPadding = maxOrdListLength - sb2.Length;
@@ -394,7 +398,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
         protected override void Dispose(bool disposing)
         {
-            if (data == null || disposing) return;
+            if (data == null || !disposing) return;
             var success = false;
             try
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
index fff24f0..97b5a85 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
@@ -34,6 +34,7 @@ namespace Lucene.Net.Codecs.SimpleText
     using BytesRef = Util.BytesRef;
     using IOUtils = Util.IOUtils;
     using StringHelper = Util.StringHelper;
+    using System.Text;
 
     /// <summary>
     /// reads plaintext field infos files
@@ -166,7 +167,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
         private static string ReadString(int offset, BytesRef scratch)
         {
-            return scratch.Bytes.SubList(scratch.Offset + offset, scratch.Length + offset).ToString();
+            return Encoding.UTF8.GetString(scratch.Bytes, scratch.Offset + offset, scratch.Length
- offset);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
index 355d360..bf72238 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
@@ -30,6 +30,7 @@ namespace Lucene.Net.Codecs.SimpleText
     using IOContext = Store.IOContext;
     using BytesRef = Util.BytesRef;
     using IOUtils = Util.IOUtils;
+    using System.Globalization;
 
     /// <summary>
     /// writes plaintext field infos files
@@ -73,7 +74,7 @@ namespace Lucene.Net.Codecs.SimpleText
             try
             {
                 SimpleTextUtil.Write(output, NUMFIELDS);
-                SimpleTextUtil.Write(output, Convert.ToString(infos.Size()), scratch);
+                SimpleTextUtil.Write(output, infos.Size().ToString(CultureInfo.InvariantCulture),
scratch);
                 SimpleTextUtil.WriteNewline(output);
 
                 foreach (FieldInfo fi in infos)
@@ -83,11 +84,11 @@ namespace Lucene.Net.Codecs.SimpleText
                     SimpleTextUtil.WriteNewline(output);
 
                     SimpleTextUtil.Write(output, NUMBER);
-                    SimpleTextUtil.Write(output, Convert.ToString(fi.Number), scratch);
+                    SimpleTextUtil.Write(output, fi.Number.ToString(CultureInfo.InvariantCulture),
scratch);
                     SimpleTextUtil.WriteNewline(output);
 
                     SimpleTextUtil.Write(output, ISINDEXED);
-                    SimpleTextUtil.Write(output, Convert.ToString(fi.Indexed), scratch);
+                    SimpleTextUtil.Write(output, fi.Indexed.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(),
scratch);
                     SimpleTextUtil.WriteNewline(output);
 
                     if (fi.Indexed)
@@ -99,15 +100,15 @@ namespace Lucene.Net.Codecs.SimpleText
                     }
 
                     SimpleTextUtil.Write(output, STORETV);
-                    SimpleTextUtil.Write(output, Convert.ToString(fi.HasVectors()), scratch);
+                    SimpleTextUtil.Write(output, fi.HasVectors().ToString(CultureInfo.InvariantCulture).ToLowerInvariant(),
scratch);
                     SimpleTextUtil.WriteNewline(output);
 
                     SimpleTextUtil.Write(output, PAYLOADS);
-                    SimpleTextUtil.Write(output, Convert.ToString(fi.HasPayloads()), scratch);
+                    SimpleTextUtil.Write(output, fi.HasPayloads().ToString(CultureInfo.InvariantCulture).ToLowerInvariant(),
scratch);
                     SimpleTextUtil.WriteNewline(output);
 
                     SimpleTextUtil.Write(output, NORMS);
-                    SimpleTextUtil.Write(output, Convert.ToString(!fi.OmitsNorms()), scratch);
+                    SimpleTextUtil.Write(output, (!fi.OmitsNorms()).ToString(CultureInfo.InvariantCulture).ToLowerInvariant(),
scratch);
                     SimpleTextUtil.WriteNewline(output);
 
                     SimpleTextUtil.Write(output, NORMS_TYPE);
@@ -119,13 +120,13 @@ namespace Lucene.Net.Codecs.SimpleText
                     SimpleTextUtil.WriteNewline(output);
 
                     SimpleTextUtil.Write(output, DOCVALUES_GEN);
-                    SimpleTextUtil.Write(output, Convert.ToString(fi.DocValuesGen), scratch);
+                    SimpleTextUtil.Write(output, fi.DocValuesGen.ToString(CultureInfo.InvariantCulture),
scratch);
                     SimpleTextUtil.WriteNewline(output);
 
                     IDictionary<string, string> atts = fi.Attributes();
                     int numAtts = atts == null ? 0 : atts.Count;
                     SimpleTextUtil.Write(output, NUM_ATTS);
-                    SimpleTextUtil.Write(output, Convert.ToString(numAtts), scratch);
+                    SimpleTextUtil.Write(output, numAtts.ToString(CultureInfo.InvariantCulture),
scratch);
                     SimpleTextUtil.WriteNewline(output);
 
                     if (numAtts <= 0 || atts == null) continue;
@@ -156,7 +157,7 @@ namespace Lucene.Net.Codecs.SimpleText
             }
         }
 
-        private static string GetDocValuesType(FieldInfo.DocValuesType_e? type)
+        private static string GetDocValuesType(DocValuesType? type)
         {
             return type.HasValue ? type.ToString() : "false";
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldsReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldsReader.cs
index cfa1467..1bc6c17 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldsReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldsReader.cs
@@ -22,6 +22,7 @@ namespace Lucene.Net.Codecs.SimpleText
     using System.Diagnostics;
     using System.Collections.Generic;
     using System.Linq;
+    using System.Text;
     using Support;
     using Util.Fst;
     
@@ -99,8 +100,8 @@ namespace Lucene.Net.Codecs.SimpleText
                 
                 if (StringHelper.StartsWith(scratch, SimpleTextFieldsWriter.FIELD))
                 {
-                    var fieldName = scratch.Bytes.SubList(scratch.Offset + SimpleTextFieldsWriter.FIELD.Length,
-                        scratch.Length - SimpleTextFieldsWriter.FIELD.Length).ToString();
+                    var fieldName = Encoding.UTF8.GetString(scratch.Bytes, scratch.Offset
+ SimpleTextFieldsWriter.FIELD.Length,
+                        scratch.Length - SimpleTextFieldsWriter.FIELD.Length);
                     fields[fieldName] = input.FilePointer;
                 }
             }
@@ -737,11 +738,14 @@ namespace Lucene.Net.Codecs.SimpleText
         {
             lock (this)
             {
-                Terms terms = _termsCache[field];
-                if (terms != null) return terms;
+                SimpleTextTerms terms;
+                if (_termsCache.TryGetValue(field, out terms))
+                {
+                    return terms;
+                }
 
-                var fp = _fields[field];
-                if (fp == null)
+                long? fp;
+                if (!_fields.TryGetValue(field, out fp) || !fp.HasValue)
                 {
                     return null;
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Codecs/SimpleText/SimpleTextSegmentInfoReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextSegmentInfoReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextSegmentInfoReader.cs
index 01236cd..eac795c 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextSegmentInfoReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextSegmentInfoReader.cs
@@ -31,6 +31,8 @@ namespace Lucene.Net.Codecs.SimpleText
     using BytesRef = Util.BytesRef;
     using IOUtils = Util.IOUtils;
     using StringHelper = Util.StringHelper;
+    using System.Text;
+    using System.Globalization;
 
     /// <summary>
     /// reads plaintext segments files
@@ -57,15 +59,15 @@ namespace Lucene.Net.Codecs.SimpleText
 
                 SimpleTextUtil.ReadLine(input, scratch);
                 Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextSegmentInfoWriter.SI_DOCCOUNT));
-                int docCount = Convert.ToInt32(ReadString(SimpleTextSegmentInfoWriter.SI_DOCCOUNT.Length,
scratch));
+                int docCount = Convert.ToInt32(ReadString(SimpleTextSegmentInfoWriter.SI_DOCCOUNT.Length,
scratch), CultureInfo.InvariantCulture);
 
                 SimpleTextUtil.ReadLine(input, scratch);
                 Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextSegmentInfoWriter.SI_USECOMPOUND));
-                bool isCompoundFile = Convert.ToBoolean(ReadString(SimpleTextSegmentInfoWriter.SI_USECOMPOUND.Length,
scratch));
+                bool isCompoundFile = Convert.ToBoolean(ReadString(SimpleTextSegmentInfoWriter.SI_USECOMPOUND.Length,
scratch), CultureInfo.InvariantCulture);
 
                 SimpleTextUtil.ReadLine(input, scratch);
                 Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextSegmentInfoWriter.SI_NUM_DIAG));
-                int numDiag = Convert.ToInt32(ReadString(SimpleTextSegmentInfoWriter.SI_NUM_DIAG.Length,
scratch));
+                int numDiag = Convert.ToInt32(ReadString(SimpleTextSegmentInfoWriter.SI_NUM_DIAG.Length,
scratch), CultureInfo.InvariantCulture);
                 IDictionary<string, string> diagnostics = new Dictionary<string,
string>();
 
                 for (int i = 0; i < numDiag; i++)
@@ -82,7 +84,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
                 SimpleTextUtil.ReadLine(input, scratch);
                 Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextSegmentInfoWriter.SI_NUM_FILES));
-                int numFiles = Convert.ToInt32(ReadString(SimpleTextSegmentInfoWriter.SI_NUM_FILES.Length,
scratch));
+                int numFiles = Convert.ToInt32(ReadString(SimpleTextSegmentInfoWriter.SI_NUM_FILES.Length,
scratch), CultureInfo.InvariantCulture);
                 var files = new HashSet<string>();
 
                 for (int i = 0; i < numFiles; i++)
@@ -115,8 +117,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
         private static string ReadString(int offset, BytesRef scratch)
         {
-            return scratch.Bytes.SubList(scratch.Offset + offset, scratch.Length - offset).ToString();
-            //return new string(scratch.Bytes, scratch.Offset + offset, scratch.Length -
offset, StandardCharsets.UTF_8);
+            return Encoding.UTF8.GetString(scratch.Bytes, scratch.Offset + offset, scratch.Length
- offset);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsReader.cs
index 2fa032c..7953828 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsReader.cs
@@ -20,6 +20,8 @@ namespace Lucene.Net.Codecs.SimpleText
 
     using System;
     using System.Diagnostics;
+    using System.Globalization;
+    using System.Text;
     using Support;
 
 	using FieldInfo = Index.FieldInfo;
@@ -185,11 +187,8 @@ namespace Lucene.Net.Codecs.SimpleText
             if (Equals(type, SimpleTextStoredFieldsWriter.TYPE_STRING))
             {
                 visitor.StringField(fieldInfo,
-                    _scratch.Bytes.SubList(_scratch.Offset + SimpleTextStoredFieldsWriter.VALUE.Length,
-                        _scratch.Length - SimpleTextStoredFieldsWriter.VALUE.Length).ToString());
-
-                   // new string(_scratch.Bytes, _scratch.Offset + SimpleTextStoredFieldsWriter.VALUE.Length,
_scratch.Length - SimpleTextStoredFieldsWriter.VALUE.Length,
-                   //     Encoding.UTF8));
+                    Encoding.UTF8.GetString(_scratch.Bytes, _scratch.Offset + SimpleTextStoredFieldsWriter.VALUE.Length,
+                        _scratch.Length - SimpleTextStoredFieldsWriter.VALUE.Length));
             }
             else if (Equals(type, SimpleTextStoredFieldsWriter.TYPE_BINARY))
             {
@@ -201,25 +200,25 @@ namespace Lucene.Net.Codecs.SimpleText
             {
                 UnicodeUtil.UTF8toUTF16(_scratch.Bytes, _scratch.Offset + SimpleTextStoredFieldsWriter.VALUE.Length,
_scratch.Length - SimpleTextStoredFieldsWriter.VALUE.Length,
                     _scratchUtf16);
-                visitor.IntField(fieldInfo, Convert.ToInt32(_scratchUtf16.ToString()));
+                visitor.IntField(fieldInfo, Convert.ToInt32(_scratchUtf16.ToString(), CultureInfo.InvariantCulture));
             }
             else if (Equals(type, SimpleTextStoredFieldsWriter.TYPE_LONG))
             {
                 UnicodeUtil.UTF8toUTF16(_scratch.Bytes, _scratch.Offset + SimpleTextStoredFieldsWriter.VALUE.Length,
_scratch.Length - SimpleTextStoredFieldsWriter.VALUE.Length,
                     _scratchUtf16);
-                visitor.LongField(fieldInfo, Convert.ToInt64(_scratchUtf16.ToString()));
+                visitor.LongField(fieldInfo, Convert.ToInt64(_scratchUtf16.ToString(), CultureInfo.InvariantCulture));
             }
             else if (Equals(type, SimpleTextStoredFieldsWriter.TYPE_FLOAT))
             {
                 UnicodeUtil.UTF8toUTF16(_scratch.Bytes, _scratch.Offset + SimpleTextStoredFieldsWriter.VALUE.Length,
_scratch.Length - SimpleTextStoredFieldsWriter.VALUE.Length,
                     _scratchUtf16);
-                visitor.FloatField(fieldInfo, Convert.ToSingle(_scratchUtf16.ToString()));
+                visitor.FloatField(fieldInfo, Convert.ToSingle(_scratchUtf16.ToString(),
CultureInfo.InvariantCulture));
             }
             else if (Equals(type, SimpleTextStoredFieldsWriter.TYPE_DOUBLE))
             {
                 UnicodeUtil.UTF8toUTF16(_scratch.Bytes, _scratch.Offset + SimpleTextStoredFieldsWriter.VALUE.Length,
_scratch.Length - SimpleTextStoredFieldsWriter.VALUE.Length,
                     _scratchUtf16);
-                visitor.DoubleField(fieldInfo, Convert.ToDouble(_scratchUtf16.ToString()));
+                visitor.DoubleField(fieldInfo, Convert.ToDouble(_scratchUtf16.ToString(),
CultureInfo.InvariantCulture));
             }
         }
 
@@ -234,7 +233,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
         protected override void Dispose(bool disposing)
         {
-            if (disposing) return;
+            if (!disposing) return;
 
             try
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Codecs/SimpleText/SimpleTextTermVectorsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextTermVectorsReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextTermVectorsReader.cs
index 666f467..46b6338 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextTermVectorsReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextTermVectorsReader.cs
@@ -23,6 +23,7 @@ namespace Lucene.Net.Codecs.SimpleText
     
     using System;
     using System.Diagnostics;
+    using System.Globalization;
     using System.Collections.Generic;
 
 	using DocsAndPositionsEnum = Index.DocsAndPositionsEnum;
@@ -138,15 +139,15 @@ namespace Lucene.Net.Codecs.SimpleText
 
                 ReadLine();
                 Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextTermVectorsWriter.FIELDPOSITIONS));
-                var positions = Convert.ToBoolean(ReadString(SimpleTextTermVectorsWriter.FIELDPOSITIONS.Length,
_scratch));
+                var positions = Convert.ToBoolean(ReadString(SimpleTextTermVectorsWriter.FIELDPOSITIONS.Length,
_scratch), CultureInfo.InvariantCulture);
 
                 ReadLine();
                 Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextTermVectorsWriter.FIELDOFFSETS));
-                var offsets = Convert.ToBoolean(ReadString(SimpleTextTermVectorsWriter.FIELDOFFSETS.Length,
_scratch));
+                var offsets = Convert.ToBoolean(ReadString(SimpleTextTermVectorsWriter.FIELDOFFSETS.Length,
_scratch), CultureInfo.InvariantCulture);
 
                 ReadLine();
                 Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextTermVectorsWriter.FIELDPAYLOADS));
-                var payloads = Convert.ToBoolean(ReadString(SimpleTextTermVectorsWriter.FIELDPAYLOADS.Length,
_scratch));
+                var payloads = Convert.ToBoolean(ReadString(SimpleTextTermVectorsWriter.FIELDPAYLOADS.Length,
_scratch), CultureInfo.InvariantCulture);
 
                 ReadLine();
                 Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextTermVectorsWriter.FIELDTERMCOUNT));
@@ -240,7 +241,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
         protected override void Dispose(bool disposing)
         {
-            if (disposing) return;
+            if (!disposing) return;
 
             try
             {
@@ -298,7 +299,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
             public override Terms Terms(string field)
             {
-                return _fields[field];
+                return _fields.ContainsKey(field) ? _fields[field] : null;
             }
 
             public override int Size

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Codecs/SimpleText/SimpleTextTermVectorsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextTermVectorsWriter.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextTermVectorsWriter.cs
index b824c15..3425006 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextTermVectorsWriter.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextTermVectorsWriter.cs
@@ -203,7 +203,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
         protected override void Dispose(bool disposing)
         {
-            if (disposing) return;
+            if (!disposing) return;
 
             try
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Core/Document/Document.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Document/Document.cs b/src/Lucene.Net.Core/Document/Document.cs
index 30b8634..1c138d4 100644
--- a/src/Lucene.Net.Core/Document/Document.cs
+++ b/src/Lucene.Net.Core/Document/Document.cs
@@ -266,7 +266,7 @@ namespace Lucene.Net.Documents
         {
             foreach (IndexableField field in fields)
             {
-                if (field.Name.Equals(name) && field.StringValue != null)
+                if (field.Name.Equals(name, System.StringComparison.Ordinal) && field.StringValue
!= null)
                 {
                     return field.StringValue;
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Core/Index/IndexWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/IndexWriter.cs b/src/Lucene.Net.Core/Index/IndexWriter.cs
index 85160bc..d8daebb 100644
--- a/src/Lucene.Net.Core/Index/IndexWriter.cs
+++ b/src/Lucene.Net.Core/Index/IndexWriter.cs
@@ -5916,7 +5916,6 @@ namespace Lucene.Net.Index
         /// </summary>
         private static bool SlowFileExists(Directory dir, string fileName)
         {
-            /*
             try
             {
                 dir.OpenInput(fileName, IOContext.DEFAULT).Dispose();
@@ -5925,8 +5924,11 @@ namespace Lucene.Net.Index
             catch (FileNotFoundException)
             {
                 return false;
-            }*/
-            return dir.FileExists(fileName);
+            }
+            catch (NoSuchFileException)
+            {
+                return false;
+            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Core/Index/SegmentInfo.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/SegmentInfo.cs b/src/Lucene.Net.Core/Index/SegmentInfo.cs
index b239435..4118e3c 100644
--- a/src/Lucene.Net.Core/Index/SegmentInfo.cs
+++ b/src/Lucene.Net.Core/Index/SegmentInfo.cs
@@ -289,7 +289,7 @@ namespace Lucene.Net.Index
                 {
                     throw new InvalidOperationException("files were not computed yet");
                 }
-                return SetFiles;//CollectionsHelper.UnmodifiableSet(SetFiles);
+                return Collections.UnmodifiableSet(SetFiles);
             }
 
             set

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Core/Index/StandardDirectoryReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/StandardDirectoryReader.cs b/src/Lucene.Net.Core/Index/StandardDirectoryReader.cs
index 72e4b26..7ee43e8 100644
--- a/src/Lucene.Net.Core/Index/StandardDirectoryReader.cs
+++ b/src/Lucene.Net.Core/Index/StandardDirectoryReader.cs
@@ -55,20 +55,20 @@ namespace Lucene.Net.Index
 
         private class FindSegmentsFileAnonymousInnerClassHelper : SegmentInfos.FindSegmentsFile
         {
-            private new readonly Directory Directory;
-            private readonly int TermInfosIndexDivisor;
+            private readonly Directory directory;
+            private readonly int termInfosIndexDivisor;
 
             public FindSegmentsFileAnonymousInnerClassHelper(Directory directory, int termInfosIndexDivisor)
                 : base(directory)
             {
-                this.Directory = directory;
-                this.TermInfosIndexDivisor = termInfosIndexDivisor;
+                this.directory = directory;
+                this.termInfosIndexDivisor = termInfosIndexDivisor;
             }
 
             protected internal override object DoBody(string segmentFileName)
             {
                 var sis = new SegmentInfos();
-                sis.Read(Directory, segmentFileName);
+                sis.Read(directory, segmentFileName);
                 var readers = new SegmentReader[sis.Size()];
                 for (int i = sis.Size() - 1; i >= 0; i--)
                 {
@@ -76,7 +76,7 @@ namespace Lucene.Net.Index
                     bool success = false;
                     try
                     {
-                        readers[i] = new SegmentReader(sis.Info(i), TermInfosIndexDivisor,
IOContext.READ);
+                        readers[i] = new SegmentReader(sis.Info(i), termInfosIndexDivisor,
IOContext.READ);
                         success = true;
                     }
                     catch (System.IO.IOException ex)
@@ -91,7 +91,7 @@ namespace Lucene.Net.Index
                         }
                     }
                 }
-                return new StandardDirectoryReader(Directory, readers, null, sis, TermInfosIndexDivisor,
false);
+                return new StandardDirectoryReader(directory, readers, null, sis, termInfosIndexDivisor,
false);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.Core/Store/TrackingDirectoryWrapper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/TrackingDirectoryWrapper.cs b/src/Lucene.Net.Core/Store/TrackingDirectoryWrapper.cs
index 028e654..5b57989 100644
--- a/src/Lucene.Net.Core/Store/TrackingDirectoryWrapper.cs
+++ b/src/Lucene.Net.Core/Store/TrackingDirectoryWrapper.cs
@@ -1,3 +1,4 @@
+using Lucene.Net.Support;
 using System.Collections.Generic;
 
 namespace Lucene.Net.Store
@@ -25,7 +26,7 @@ namespace Lucene.Net.Store
     /// </summary>
     public sealed class TrackingDirectoryWrapper : FilterDirectory
     {
-        private readonly ISet<string> CreatedFileNames = new HashSet<string>();
+        private readonly ISet<string> CreatedFileNames = new ConcurrentHashSet<string>();
 
         public TrackingDirectoryWrapper(Directory @in)
             : base(@in)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/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 d220833..18576b7 100644
--- a/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
+++ b/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
@@ -301,8 +301,9 @@ namespace Lucene.Net.Store
                     {
                         f.Dispose();
                     }
-                    catch (Exception)
+                    catch (Exception ex)
                     {
+                        Debug.WriteLine("Crash(): f.Dispose() FAILED for {0}:\n{1}", f.ToString(),
ex.ToString());
                     }
                 }
 
@@ -741,13 +742,16 @@ namespace Lucene.Net.Store
                 if (OpenFiles.TryGetValue(name, out v))
                 {
                     v++;
+                    //Debug.WriteLine("Add {0} - {1} - {2}", c, name, v);
                     OpenFiles[name] = v;
                 }
                 else
                 {
+                    //Debug.WriteLine("Add {0} - {1} - {2}", c, name, 1);
                     OpenFiles[name] = 1;
-                    OpenFileHandles[c] = new Exception("unclosed Index" + handle.ToString()
+ ": " + name);
                 }
+
+                OpenFileHandles[c] = new Exception("unclosed Index" + handle.ToString() +
": " + name);
             }
         }
 
@@ -1087,16 +1091,19 @@ namespace Lucene.Net.Store
                 {
                     if (v == 1)
                     {
+                        //Debug.WriteLine("RemoveOpenFile OpenFiles.Remove {0} - {1}", c,
name);
                         OpenFiles.Remove(name);
-                        Exception _;
-                        OpenFileHandles.TryRemove(c, out _);
                     }
                     else
                     {
                         v--;
                         OpenFiles[name] = v;
+                        //Debug.WriteLine("RemoveOpenFile OpenFiles DECREMENT {0} - {1} -
{2}", c, name, v);
                     }
                 }
+
+                Exception _;
+                OpenFileHandles.TryRemove(c, out _);
             }
         }
 
@@ -1342,7 +1349,7 @@ namespace Lucene.Net.Store
                     if (disposing)
                     {
                         DelegateHandle.Dispose();
-                        OuterInstance.RemoveOpenFile(this, Name);
+                        OuterInstance.RemoveOpenFile(OuterInstance, Name);
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/166ef1ee/src/Lucene.Net.TestFramework/Store/MockIndexInputWrapper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Store/MockIndexInputWrapper.cs b/src/Lucene.Net.TestFramework/Store/MockIndexInputWrapper.cs
index 1adc4b0..7bb594e 100644
--- a/src/Lucene.Net.TestFramework/Store/MockIndexInputWrapper.cs
+++ b/src/Lucene.Net.TestFramework/Store/MockIndexInputWrapper.cs
@@ -49,7 +49,7 @@ namespace Lucene.Net.Store
             {
                 // turn on the following to look for leaks closing inputs,
                 // after fixing TestTransactions
-                Dir.MaybeThrowDeterministicException();
+                // Dir.MaybeThrowDeterministicException();
             }
             finally
             {
@@ -62,10 +62,6 @@ namespace Lucene.Net.Store
                 {
                     Dir.RemoveIndexInput(this, Name);
                 }
-                else
-                {
-                    //Could this be where things aren't being deleted?
-                }
             }
         }
 


Mime
View raw message