lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [1/3] lucenenet git commit: Fixing NRE
Date Sun, 01 Mar 2015 22:56:28 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master 9ff490365 -> aabf15fdb


Fixing NRE


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

Branch: refs/heads/master
Commit: 979403c21364be8df5bb764ae3dc4e361d016062
Parents: 9ff4903
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Mon Mar 2 00:53:09 2015 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Mon Mar 2 00:53:09 2015 +0200

----------------------------------------------------------------------
 .../Codecs/lucene40/Lucene40DocValuesWriter.cs      | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/979403c2/src/Lucene.Net.TestFramework/Codecs/lucene40/Lucene40DocValuesWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/lucene40/Lucene40DocValuesWriter.cs b/src/Lucene.Net.TestFramework/Codecs/lucene40/Lucene40DocValuesWriter.cs
index e8cfda1..4d634a4 100644
--- a/src/Lucene.Net.TestFramework/Codecs/lucene40/Lucene40DocValuesWriter.cs
+++ b/src/Lucene.Net.TestFramework/Codecs/lucene40/Lucene40DocValuesWriter.cs
@@ -172,24 +172,26 @@ namespace Lucene.Net.Codecs.Lucene40
             HashSet<BytesRef> uniqueValues = new HashSet<BytesRef>();
             int minLength = int.MaxValue;
             int maxLength = int.MinValue;
-            BytesRef brefDummy;
-            foreach (BytesRef b in values)
+
+            var vals = values.ToArray();
+
+            for (int i = 0; i < vals.Length; i++)
             {
-                brefDummy = b;
+                var b = vals[i];
 
                 if (b == null)
                 {
-                    brefDummy = new BytesRef(); // 4.0 doesnt distinguish
+                    b = vals[i] = new BytesRef(); // 4.0 doesnt distinguish
                 }
                 if (b.Length > Lucene40DocValuesFormat.MAX_BINARY_FIELD_LENGTH)
                 {
                     throw new System.ArgumentException("DocValuesField \"" + field.Name +
"\" is too large, must be <= " + Lucene40DocValuesFormat.MAX_BINARY_FIELD_LENGTH);
                 }
-                minLength = Math.Min(minLength, brefDummy.Length);
-                maxLength = Math.Max(maxLength, brefDummy.Length);
+                minLength = Math.Min(minLength, b.Length);
+                maxLength = Math.Max(maxLength, b.Length);
                 if (uniqueValues != null)
                 {
-                    if (uniqueValues.Add(BytesRef.DeepCopyOf(brefDummy)))
+                    if (uniqueValues.Add(BytesRef.DeepCopyOf(b)))
                     {
                         if (uniqueValues.Count > 256)
                         {


Mime
View raw message