Skip to content

Check whether file is found before trying to dereference it #759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 30, 2020

Conversation

GoEddie
Copy link
Contributor

@GoEddie GoEddie commented Oct 28, 2020

Fixes #758

The current code causes a NullReferenceException when the assembly cannot be found so this switches the logic slightly and also adds some additional detail to describe how the DOTNET_ASSEMBLY_SEARCH_PATHS environment variable is set to help users understand why their dll's are not being loaded.

I wasn't sure on writing a test for this, if it needs a test let me know, I did think about adding a check for a FileNotFoundException for a file that doesn't exist and call UdfSerDe.Deserialize(UdfData udfData).

I was also unsure what to throw if the assembly had been loaded but the type couldn't for some reason, I went with TypeLoadException but let me know if you think something else is more appropriate.

The point of this really is that I have seen this pop up a few times and the NullReferenceException hides a genuinely useful FileNotFoundException.

Ed

@imback82
Copy link
Contributor

Thanks @GoEddie. I think this can be useful. @suhsteve Can you help with the review? Thanks!

@GoEddie GoEddie requested a review from suhsteve October 29, 2020 08:16
Co-authored-by: Steve Suh <suhsteve@gmail.com>
Copy link
Member

@suhsteve suhsteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @GoEddie !

Copy link
Contributor

@imback82 imback82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @GoEddie!

@imback82 imback82 merged commit d252590 into dotnet:master Oct 30, 2020
@imback82 imback82 added this to the 1.0.1 milestone Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: UDF SerDe cannot get to FileNotFoundException because of null reference exception
3 participants