This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit 8f090ba813edd5cca489968a1ae3c21c811f6139
Author: Shad Storhaug <[email protected]>
AuthorDate: Mon Aug 5 01:48:04 2019 +0700

    BUG: Lucene.Net.Tests.Index.TestTransactionRollback: Number was failing due 
to the fact the data that was being populated wasn't being converted from int 
to string in invariant culture. Switched back to original logic, using 
LastIndexOf(char) rather than LastIndexOf(string).
---
 src/Lucene.Net.Tests/Index/TestTransactionRollback.cs | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/Lucene.Net.Tests/Index/TestTransactionRollback.cs 
b/src/Lucene.Net.Tests/Index/TestTransactionRollback.cs
index 8a162de..ca58e05 100644
--- a/src/Lucene.Net.Tests/Index/TestTransactionRollback.cs
+++ b/src/Lucene.Net.Tests/Index/TestTransactionRollback.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Globalization;
 using Lucene.Net.Documents;
 
 namespace Lucene.Net.Index
@@ -72,7 +73,7 @@ namespace Lucene.Net.Index
 
             IndexWriter w = new IndexWriter(Dir, 
NewIndexWriterConfig(TEST_VERSION_CURRENT, new 
MockAnalyzer(Random())).SetIndexDeletionPolicy(new RollbackDeletionPolicy(this, 
id)).SetIndexCommit(last));
             IDictionary<string, string> data = new Dictionary<string, 
string>();
-            data["index"] = "Rolled back to 1-" + id;
+            data["index"] = "Rolled back to 1-" + 
id.ToString(CultureInfo.InvariantCulture);
             w.SetCommitData(data);
             w.Dispose();
         }
@@ -145,13 +146,13 @@ namespace Lucene.Net.Index
             for (int currentRecordId = 1; currentRecordId <= 100; 
currentRecordId++)
             {
                 Document doc = new Document();
-                doc.Add(NewTextField(FIELD_RECORD_ID, "" + currentRecordId, 
Field.Store.YES));
+                doc.Add(NewTextField(FIELD_RECORD_ID, 
currentRecordId.ToString(CultureInfo.InvariantCulture), Field.Store.YES));
                 w.AddDocument(doc);
 
                 if (currentRecordId % 10 == 0)
                 {
                     IDictionary<string, string> data = new Dictionary<string, 
string>();
-                    data["index"] = "records 1-" + currentRecordId;
+                    data["index"] = "records 1-" + 
currentRecordId.ToString(CultureInfo.InvariantCulture);
                     w.SetCommitData(data);
                     w.Commit();
                 }
@@ -195,12 +196,8 @@ namespace Lucene.Net.Index
                         // this code reads the last id ("30" in this example) 
and deletes it
                         // if it is after the desired rollback point
                         string x = userData["index"];
-
-                        // LUCENENET specific - Bug in the original when "-" 
is the last character in
-                        // the string, it tries to match one larger than what 
is available.
-                        int lastIndex = x.LastIndexOf("-");
-                        string lastVal = x.Substring(lastIndex + 1 == x.Length 
? lastIndex : lastIndex + 1);
-                        int last = Convert.ToInt32(lastVal);
+                        string lastVal = x.Substring(x.LastIndexOf('-') + 1);
+                        int last = Convert.ToInt32(lastVal, 
CultureInfo.InvariantCulture);
                         if (last > RollbackPoint)
                         {
                             /*

Reply via email to