lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [1/4] lucenenet git commit: IcuBreakIterator: Added error handling to catch AccessViolationException (due to an apparent bug in icu-dotnet)
Date Wed, 05 Apr 2017 22:01:38 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/api-work f5a7bc3f7 -> 240a6bfa5


IcuBreakIterator: Added error handling to catch AccessViolationException (due to an apparent
bug in icu-dotnet)


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

Branch: refs/heads/api-work
Commit: 94813f50376f1707a879860475c54ac1dbd453a7
Parents: f5a7bc3
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Thu Apr 6 01:16:44 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Thu Apr 6 05:01:10 2017 +0700

----------------------------------------------------------------------
 src/IcuBreakIterator.cs | 41 ++++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/94813f50/src/IcuBreakIterator.cs
----------------------------------------------------------------------
diff --git a/src/IcuBreakIterator.cs b/src/IcuBreakIterator.cs
index 6028ba1..f67915b 100644
--- a/src/IcuBreakIterator.cs
+++ b/src/IcuBreakIterator.cs
@@ -292,28 +292,35 @@ namespace Lucene.Net
             IEnumerable<Icu.Boundary> icuBoundaries;
             string offsetText = text.Substring(start, end - start);
 
-            if (type == Icu.BreakIterator.UBreakIteratorType.WORD)
+            try
             {
-                if (enableHacks)
+                if (type == Icu.BreakIterator.UBreakIteratorType.WORD)
                 {
-                    // LUCENENET TODO: HACK - replacing hyphen with "a" so hyphenated words
aren't broken
-                    offsetText = offsetText.Replace("-", "a");
+                    if (enableHacks)
+                    {
+                        // LUCENENET TODO: HACK - replacing hyphen with "a" so hyphenated
words aren't broken
+                        offsetText = offsetText.Replace("-", "a");
+                    }
+
+                    icuBoundaries = Icu.BreakIterator.GetWordBoundaries(locale, offsetText,
true);
                 }
-                
-                icuBoundaries = Icu.BreakIterator.GetWordBoundaries(locale, offsetText, true);
-            }
-            else
-            {
-                if (enableHacks && type == Icu.BreakIterator.UBreakIteratorType.SENTENCE)
+                else
                 {
-                    // LUCENENET TODO: HACK - newline character causes incorrect sentence
breaking.
-                    offsetText = offsetText.Replace("\n", " ");
-                    // LUCENENET TODO: HACK - the ICU sentence logic doesn't work (in English
anyway) when sentences don't
-                    // begin with capital letters.
-                    offsetText = CapitalizeFirst(offsetText);
+                    if (enableHacks && type == Icu.BreakIterator.UBreakIteratorType.SENTENCE)
+                    {
+                        // LUCENENET TODO: HACK - newline character causes incorrect sentence
breaking.
+                        offsetText = offsetText.Replace("\n", " ");
+                        // LUCENENET TODO: HACK - the ICU sentence logic doesn't work (in
English anyway) when sentences don't
+                        // begin with capital letters.
+                        offsetText = CapitalizeFirst(offsetText);
+                    }
+
+                    icuBoundaries = Icu.BreakIterator.GetBoundaries(type, locale, offsetText);
                 }
-
-                icuBoundaries = Icu.BreakIterator.GetBoundaries(type, locale, offsetText);
+            }
+            catch (AccessViolationException ace)
+            {
+                throw new Exception("Hit AccessViolationException: " + ace.ToString(), ace);
             }
 
             boundaries = icuBoundaries


Mime
View raw message