Skip to content

Commit

Permalink
SWEEP: Reviewed all catch blocks where Lucene uses IOException and co…
Browse files Browse the repository at this point in the history
…nverted them to use our IsIOException() extension method (see apache#446).
  • Loading branch information
NightOwl888 committed Apr 14, 2021
1 parent d028566 commit 97e04e6
Show file tree
Hide file tree
Showing 196 changed files with 556 additions and 701 deletions.
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Ar/ArabicAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Standard;
Expand Down Expand Up @@ -72,7 +72,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
{
return LoadStopwordSet(false, typeof(ArabicAnalyzer), DEFAULT_STOPWORD_FILE, "#");
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Standard;
Expand Down Expand Up @@ -65,7 +65,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
{
return LoadStopwordSet(false, typeof(BulgarianAnalyzer), DEFAULT_STOPWORD_FILE, "#");
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Standard;
Expand Down Expand Up @@ -64,7 +64,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
LuceneVersion.LUCENE_CURRENT);
#pragma warning restore 612, 618
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Ca/CatalanAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Snowball;
Expand Down Expand Up @@ -70,7 +70,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
{
return LoadStopwordSet(false, typeof(CatalanAnalyzer), DEFAULT_STOPWORD_FILE, "#");
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Diagnostics;
using Lucene.Net.Util;
using Lucene.Net.Util.Fst;
Expand Down Expand Up @@ -66,7 +66,7 @@ private NormalizeCharMap(FST<CharsRef> map)
}
//System.out.println("cached " + cachedRootArcs.size() + " root arcs");
}
catch (IOException ioe)
catch (Exception ioe) when (ioe.IsIOException())
{
// Bogus FST IOExceptions!! (will never happen)
throw new Exception("Should never happen", ioe);
Expand Down Expand Up @@ -130,7 +130,7 @@ public virtual NormalizeCharMap Build()
map = builder.Finish();
pendingPairs.Clear();
}
catch (IOException ioe)
catch (Exception ioe) when (ioe.IsIOException())
{
// Bogus FST IOExceptions!! (will never happen)
throw new Exception("Should never happen", ioe);
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Cjk/CJKAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Standard;
using Lucene.Net.Analysis.Util;
Expand Down Expand Up @@ -56,7 +56,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
{
return LoadStopwordSet(false, typeof(CJKAnalyzer), DEFAULT_STOPWORD_FILE, "#");
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Ckb/SoraniAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Standard;
Expand Down Expand Up @@ -61,7 +61,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
LuceneVersion.LUCENE_CURRENT);
#pragma warning restore 612, 618
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Cz/CzechAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Standard;
Expand Down Expand Up @@ -72,7 +72,7 @@ private static CharArraySet LoadDefaultSet() // LUCENENET: Avoid static construc
LuceneVersion.LUCENE_CURRENT);
#pragma warning restore 612, 618
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Da/DanishAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Snowball;
Expand Down Expand Up @@ -63,7 +63,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
LuceneVersion.LUCENE_CURRENT);
#pragma warning restore 612, 618
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/De/GermanAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Snowball;
Expand Down Expand Up @@ -99,7 +99,7 @@ private static CharArraySet LoadDefaultSet() // LUCENENET: Avoid static construc
LuceneVersion.LUCENE_CURRENT);
#pragma warning restore 612, 618
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/El/GreekAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Standard;
using Lucene.Net.Analysis.Util;
Expand Down Expand Up @@ -64,7 +64,7 @@ private static CharArraySet LoadDefaultSet() // LUCENENET: Avoid static construc
{
return LoadStopwordSet(false, typeof(GreekAnalyzer), DEFAULT_STOPWORD_FILE, "#");
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/En/PorterStemmer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Support;
using Lucene.Net.Util;
using System;
Expand Down Expand Up @@ -861,7 +861,7 @@ public virtual bool Stem(int i0)
// }
// }
// }
// catch (IOException e)
// catch (Exception e) when (ex.IsIOException())
// {
// Console.WriteLine("error reading " + args[i]);
// Console.WriteLine(e.ToString());
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Es/SpanishAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Snowball;
Expand Down Expand Up @@ -71,7 +71,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
LuceneVersion.LUCENE_CURRENT);
#pragma warning restore 612, 618
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Eu/BasqueAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Snowball;
Expand Down Expand Up @@ -58,7 +58,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
{
return LoadStopwordSet(false, typeof(BasqueAnalyzer), DEFAULT_STOPWORD_FILE, "#");
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Fa/PersianAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Ar;
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Standard;
Expand Down Expand Up @@ -71,7 +71,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
{
return LoadStopwordSet(false, typeof(PersianAnalyzer), DEFAULT_STOPWORD_FILE, STOPWORDS_COMMENT);
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Fi/FinnishAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Snowball;
Expand Down Expand Up @@ -63,7 +63,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
LuceneVersion.LUCENE_CURRENT);
#pragma warning restore 612, 618
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Fr/FrenchAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Snowball;
Expand Down Expand Up @@ -121,7 +121,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
LuceneVersion.LUCENE_CURRENT);
#pragma warning restore 612, 618
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Ga/IrishAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Snowball;
Expand Down Expand Up @@ -75,7 +75,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
{
return LoadStopwordSet(false, typeof(IrishAnalyzer), DEFAULT_STOPWORD_FILE, "#");
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Standard;
Expand Down Expand Up @@ -61,7 +61,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
LuceneVersion.LUCENE_CURRENT);
#pragma warning restore 612, 618
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Hi/HindiAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.In;
using Lucene.Net.Analysis.Miscellaneous;
Expand Down Expand Up @@ -68,7 +68,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
{
return LoadStopwordSet(false, typeof(HindiAnalyzer), DEFAULT_STOPWORD_FILE, STOPWORDS_COMMENT);
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Snowball;
Expand Down Expand Up @@ -63,7 +63,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
LuceneVersion.LUCENE_CURRENT);
#pragma warning restore 612, 618
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ internal virtual Int32sRef Lookup(FST<Int32sRef> fst, char[] word, int offset, i
return output;
}
}
catch (IOException bogus)
catch (Exception bogus) when (bogus.IsIOException())
{
throw new Exception(bogus.Message, bogus);
}
Expand Down Expand Up @@ -1392,7 +1392,7 @@ internal virtual string CleanInput(string input, StringBuilder reuse)
{
ApplyMappings(iconv, reuse);
}
catch (IOException bogus)
catch (Exception bogus) when (bogus.IsIOException())
{
throw new Exception(bogus.Message, bogus);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Stemmer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private IList<CharsRef> DoStem(char[] word, int length, bool caseVariant)
{
stems.AddRange(Stem(word, length, -1, -1, -1, 0, true, true, false, false, caseVariant));
}
catch (IOException bogus)
catch (Exception bogus) when (bogus.IsIOException())
{
throw new Exception(bogus.ToString(), bogus);
}
Expand Down Expand Up @@ -297,7 +297,7 @@ private CharsRef NewStem(char[] buffer, int length, Int32sRef forms, int formID)
{
Dictionary.ApplyMappings(dictionary.oconv, scratchSegment);
}
catch (IOException bogus)
catch (Exception bogus) when (bogus.IsIOException())
{
throw new Exception(bogus.Message, bogus);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Snowball;
Expand Down Expand Up @@ -58,7 +58,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
{
return LoadStopwordSet(false, typeof(ArmenianAnalyzer), DEFAULT_STOPWORD_FILE, "#");
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lucene version compatibility level 4.8.1
// Lucene version compatibility level 4.8.1
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Standard;
Expand Down Expand Up @@ -54,7 +54,7 @@ private static CharArraySet LoadDefaultStopSet() // LUCENENET: Avoid static cons
{
return LoadStopwordSet(false, typeof(IndonesianAnalyzer), DEFAULT_STOPWORD_FILE, "#");
}
catch (IOException ex)
catch (Exception ex) when (ex.IsIOException())
{
// default set should always be present as it is part of the
// distribution (JAR)
Expand Down
Loading

0 comments on commit 97e04e6

Please sign in to comment.