You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am simply trying to create a StandardQueryParser. I get the below exception only on Android and iOS. This makes sense as System.Console.In is not supported on these platforms, but I have no need for it in the context of our application. So, I think a way to ignore this would be very useful to prevent our app from crashing on these platforms.
Note that I am testing on Android and iOS in Android Studio and XCode respectively, not on physical devices. Though, I don't think this will make a difference.
It seems the issue is the way these properties are setup in Lucene.Net.Util.SystemConsole.
public static TextWriter Out { get; set; } = Console.Out;
public static TextWriter Error { get; set; } = Console.Error;
public static TextReader In { get; set; } = Console.In;
My application would work fine to simply return null here when Console.In is not supported.
I can't seem to find anything online about this regarding Lucene, so I think it is just specific to Lucene.NET and .NET MAUI. In any case, I believe it can possibly be addressed simply by doing the above.
From what I can tell, SystemConsole is only used in StandardSyntaxParserTokenManager to create the private debugStream property, which is then never used in this class. I believe this whole thing is the same when using the default QueryParser as well.
Expected Behavior
Perhaps instead of defaulting to Console.In, the property can be set in a way that if a non-supported or any other exceptions that can be ignored is caught, this property returns null or a bogus TextReader by default.
Steps To Reproduce
In a .NET MAUI sample app, create a Lucene.Net.QueryParsers.Flexible.Standard.StandardQueryParser using the constructor.
Specifically we created our MAUI app using the default template in Rider.
Run the app.
on Windows and macOS, this will run fine. On Android and iOS, the app will crash with a System.PlatformNotSupportedException when it attempts to construct the StandardQueryParser.
Exceptions (if any)
Exception: System.TypeInitializationException: The type initializer for 'Lucene.Net.Util.SystemConsole' threw an exception.
---> System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.ConsolePal.GetOrCreateReader()
at System.Console.<get_In>g__EnsureInitialized|14_0()
at System.Console.get_In()
2024-04-29 15:55:32.051142-0700 at Lucene.Net.Util.SystemConsole..cctor()
--- End of inner exception stack trace ---
at Lucene.Net.QueryParsers.Flexible.Standard.Parser.StandardSyntaxParserTokenManager..ctor(ICharStream stream)
2024-04-29 15:55:32.051200-0700 at Lucene.Net.QueryParsers.Flexible.Standard.Parser.StandardSyntaxParser..ctor(ICharStream stream)
at Lucene.Net.QueryParsers.Flexible.Standard.Parser.StandardSyntaxParser..ctor()
at Lucene.Net.QueryParsers.Flexible.Standard.StandardQueryParser..ctor()
2024-04-29 15:55:32.051439-0700 at Lucene.Net.QueryParsers.Flexible.Standard.StandardQueryParser..ctor(Analyzer analyzer)
Lucene.NET Version
4.8
.NET Version
8.0.203
Operating System
Windows 11
Anything else?
No response
The text was updated successfully, but these errors were encountered:
…nManager
* When debugStream is set to Console.Out by default, constructing a StandardQueryParser throws an exception on OSes that do not support Console, such as iOS and Android.
* debugStream can be set later using the setter, if needed.
* See issue apache#936 for details.
JayOfemi
added a commit
to TheBrainTech/LuceneNet
that referenced
this issue
Jun 11, 2024
* 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.
JayOfemi
added a commit
to TheBrainTech/LuceneNet
that referenced
this issue
Jun 11, 2024
* 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.
Is there an existing issue for this?
Describe the bug
I am simply trying to create a StandardQueryParser. I get the below exception only on Android and iOS. This makes sense as
System.Console.In
is not supported on these platforms, but I have no need for it in the context of our application. So, I think a way to ignore this would be very useful to prevent our app from crashing on these platforms.Note that I am testing on Android and iOS in Android Studio and XCode respectively, not on physical devices. Though, I don't think this will make a difference.
It seems the issue is the way these properties are setup in
Lucene.Net.Util.SystemConsole
.My application would work fine to simply return null here when Console.In is not supported.
I can't seem to find anything online about this regarding Lucene, so I think it is just specific to Lucene.NET and .NET MAUI. In any case, I believe it can possibly be addressed simply by doing the above.
From what I can tell,
SystemConsole
is only used inStandardSyntaxParserTokenManager
to create the privatedebugStream
property, which is then never used in this class. I believe this whole thing is the same when using the default QueryParser as well.Expected Behavior
Perhaps instead of defaulting to
Console.In
, the property can be set in a way that if a non-supported or any other exceptions that can be ignored is caught, this property returns null or a bogus TextReader by default.Steps To Reproduce
Lucene.Net.QueryParsers.Flexible.Standard.StandardQueryParser
using the constructor.on Windows and macOS, this will run fine. On Android and iOS, the app will crash with a
System.PlatformNotSupportedException
when it attempts to construct theStandardQueryParser
.Exceptions (if any)
Lucene.NET Version
4.8
.NET Version
8.0.203
Operating System
Windows 11
Anything else?
No response
The text was updated successfully, but these errors were encountered: