lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shad Storhaug (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENENET-593) NullReferenceException in Linux
Date Fri, 11 Aug 2017 21:46:00 GMT

    [ https://issues.apache.org/jira/browse/LUCENENET-593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16124138#comment-16124138
] 

Shad Storhaug commented on LUCENENET-593:
-----------------------------------------

Hi Warren,

Thanks for the PR, and for letting me know this isn't an issue with .NET Standard.

Yes, I was referring to that .NET Standard block.

However, I realized after taking a deeper dive into the code that almost none of the Constants
class is working correctly, in particular, the original Java code was using the value of the
OS_NAME variable to identify the OS platform using string matching, which was completely broken.
But after some research, I found that there are more reliable ways of making these checks
in .NET. Also, there is no reason to use environment variables here.

The check for .NET Framework version was also not working correctly, I put in an exclusion
for non-Windows so it doesn't blow up on Linux when attempting to dig through the registry.

I have pushed the changes to master. You can check them out on the CI build in a couple of
hours: https://www.myget.org/gallery/lucene-net-ci. Unfortunately, I can't accept the PR as
we don't really want to add a dependency to .NET Framework, since we already have an API (Environment.Is64BitOperatingSystem)
we can use to determine the OS architecture (or at least it is good enough for diagnostic
purposes).

Please confirm in your Linux environment that:

1. Constants.LINUX is true
2. Constants.WINDOWS is false
3. Constants.OS_NAME (used for diagnositcs) indicates that you are on Linux
4. Constants.OS_VERSION is correct (also used for diagnostics)
5. Constants.RUNTIME_VERSION matches your .NET Framework version. Since Microsoft requires
us to dig through the registry to accurately determine framework version, this will probably
be 4.0 on Linux, but I am not sure what else we can do about this.
6. CONSTANTS.OS_ARCH is the correct bitness.

The only real functionality that changes here is with a 64 bit .NET Framework, there will
be extra memory allocation on arrays, and the FSDirectory.Open() static method returns MMapDirectory
if 64 bit and NIOFSDirectory if 32 bit on Linux.

Let us know if anything looks off or submit another PR with a fix.





> NullReferenceException in Linux
> -------------------------------
>
>                 Key: LUCENENET-593
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-593
>             Project: Lucene.Net
>          Issue Type: Bug
>          Components: Lucene.Net Core
>    Affects Versions: Lucene.Net 4.8.0, Lucene.Net 5.0 PCL
>         Environment: Linux (ubuntu 64 bit, maybe all linux variants)
>            Reporter: Warren Falk
>
> A NullReferenceException on any attempt to query in Linux (ubuntu x64 in my tests)
> I was able to track this down to the following line in Constants.cs
>         {{public static readonly string OS_ARCH = GetEnvironmentVariable("PROCESSOR_ARCHITECTURE",
"x86");}}
> Sure enough, PROCESSOR_ARCHITECTURE is not set by default in ubuntu server x64 and when
I set it, there is no failure.
> I would fix this, but I'm not sure what this value is used for, so I am not sure what
the appropriate behavior should be.  Should we try to find the correct architecture here?
 And what is the correct string, "amd64", "x64", "x86_64"?  Or do we really just want to know
the value of that if it is actually not set, should we leave it blank?  The issue is that
the InfoWriter can't write a null, but it could write an empty string.
> I'll submit a pull request if anyone can tell me what correct behavior should be.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message