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 fc77ea2cd0e24456111bc44cb75d64653473cdfc Author: Shad Storhaug <[email protected]> AuthorDate: Mon Feb 22 04:26:44 2021 +0700 SWEEP: MemberwiseClone() doesn't throw exceptions in .NET, so there is no need to place it in a try/catch block. There is also no need to cast the result if we don't need access to its members. (#259) --- src/Lucene.Net/Search/Query.cs | 11 ++--------- src/Lucene.Net/Util/InfoStream.cs | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/Lucene.Net/Search/Query.cs b/src/Lucene.Net/Search/Query.cs index c2825d6..26e86f4 100644 --- a/src/Lucene.Net/Search/Query.cs +++ b/src/Lucene.Net/Search/Query.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace Lucene.Net.Search @@ -117,14 +117,7 @@ namespace Lucene.Net.Search /// Returns a clone of this query. </summary> public virtual object Clone() { - try - { - return (Query)base.MemberwiseClone(); - } - catch (Exception e) - { - throw new Exception("Clone not supported: " + e.Message); - } + return MemberwiseClone(); // LUCENENET: MemberwiseClone() never throws in .NET and there is no need to cast the result here. } public override int GetHashCode() diff --git a/src/Lucene.Net/Util/InfoStream.cs b/src/Lucene.Net/Util/InfoStream.cs index d29a684..30e8014 100644 --- a/src/Lucene.Net/Util/InfoStream.cs +++ b/src/Lucene.Net/Util/InfoStream.cs @@ -1,4 +1,4 @@ -using System; +using System; using Lucene.Net.Diagnostics; namespace Lucene.Net.Util @@ -110,14 +110,7 @@ namespace Lucene.Net.Util /// </summary> public virtual object Clone() { - try - { - return (InfoStream)base.MemberwiseClone(); - } - catch (InvalidOperationException e) - { - throw new Exception(e.ToString(), e); - } + return MemberwiseClone(); // LUCENENET: No exception can occur in .NET and there is no need to cast. } } } \ No newline at end of file
