Skip to content

Commit

Permalink
Leave debugStream as null on construction of parser token managers
Browse files Browse the repository at this point in the history
* When debugStream is set to Console.Out by default, StandardSyntaxParserTokenManager throws an exception when constructing a StandardQueryParser on OSes that do not support System.Console, such as iOS and Android.
* debugStream can be set later using the setter, if needed.
* The above is the same for QueryParserTokenManager when constructing a QueryParser.
* See issue apache#936 for details.
  • Loading branch information
JayOfemi committed Jun 11, 2024
1 parent 38a7b53 commit dad1c51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Lucene.Net.QueryParser/Classic/QueryParserTokenManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class QueryParserTokenManager //: QueryParserConstants
{
/// <summary>Debug output. </summary>
#pragma warning disable IDE0052 // Remove unread private members
private TextWriter debugStream = Console.Out; // LUCENENET specific - made private, since we already have a setter
private TextWriter debugStream; // LUCENENET specific - made private, since we already have a setter
#pragma warning restore IDE0052 // Remove unread private members
/// <summary>Set debug output. </summary>
public virtual void SetDebugStream(TextWriter ds)
Expand Down Expand Up @@ -1162,7 +1162,7 @@ public QueryParserTokenManager(ICharStream stream)
m_input_stream = stream;
}

/// <summary>Constructor.
/// <summary>Constructor.
/// <para>Note that this constructor calls a virtual method <see cref="SwitchTo(int)" />. If you
/// are subclassing this class, use <see cref="QueryParserTokenManager(ICharStream)" /> constructor and
/// call SwitchTo if needed.</para>
Expand Down Expand Up @@ -1358,4 +1358,4 @@ private void JjCheckNAddStates(int start, int end)
while (start++ != end);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Lucene.Net.Support.IO;
using Lucene.Net.Support.IO;
using System.Diagnostics.CodeAnalysis;
using System;
using System.IO;
Expand Down Expand Up @@ -32,7 +32,7 @@ public class StandardSyntaxParserTokenManager /*: StandardSyntaxParserConstants*
{
/// <summary>Debug output.</summary>
#pragma warning disable IDE0052 // Remove unread private members
private TextWriter debugStream = Console.Out; // LUCENENET specific - made private, since we already have a setter
private TextWriter debugStream; // LUCENENET specific - made private, since we already have a setter
#pragma warning restore IDE0052 // Remove unread private members
/// <summary>Set debug output.</summary>
public void SetDebugStream(TextWriter ds) { debugStream = new SafeTextWriterWrapper(ds); }
Expand Down

0 comments on commit dad1c51

Please sign in to comment.