lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [4/4] lucenenet git commit: BUG: Lucene.Net.Tests.Index.TestTransactionRollback: Fixed issue where the value passed to substring could potentially go beyond the length of the string.
Date Mon, 11 Sep 2017 14:34:59 GMT
BUG: Lucene.Net.Tests.Index.TestTransactionRollback: Fixed issue where the value passed to
substring could potentially go beyond the length of the string.


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

Branch: refs/heads/master
Commit: 573dd303a92d2f66fe72367576e51676c0c78ccd
Parents: cb3215a
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Mon Sep 11 21:33:46 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Mon Sep 11 21:33:46 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Tests/Index/TestTransactionRollback.cs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/573dd303/src/Lucene.Net.Tests/Index/TestTransactionRollback.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestTransactionRollback.cs b/src/Lucene.Net.Tests/Index/TestTransactionRollback.cs
index ef6520b..8a162de 100644
--- a/src/Lucene.Net.Tests/Index/TestTransactionRollback.cs
+++ b/src/Lucene.Net.Tests/Index/TestTransactionRollback.cs
@@ -195,7 +195,11 @@ 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"];
-                        string lastVal = x.Substring(x.LastIndexOf("-") + 1);
+
+                        // 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);
                         if (last > RollbackPoint)
                         {


Mime
View raw message