Skip to content

Fix Get failing with a null exception #1924

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

Closed

Conversation

RogerKratz
Copy link
Contributor

@RogerKratz RogerKratz commented Dec 6, 2018

Fixes #1920

@fredericDelaporte fredericDelaporte changed the title Failing test for #1920 Fix Get failing with a null exception Dec 6, 2018
@fredericDelaporte fredericDelaporte changed the title Fix Get failing with a null exception WIP - Fix Get failing with a null exception Dec 6, 2018
@fredericDelaporte

This comment has been minimized.

@fredericDelaporte fredericDelaporte changed the title WIP - Fix Get failing with a null exception Fix Get failing with a null exception Dec 6, 2018
@fredericDelaporte
Copy link
Member

I do not see how we could "get" a collection without having it previously loaded as an uninitialized proxy, but I still have changed in the same way its loading logic. (The nearer to a "get" for a collection would be an entity load with a collection fetch, but that does not trigger batching.)

@RogerKratz
Copy link
Contributor Author

I was about to suggest writing a test for "collection case", but reading your last comment I understand this change was just "a safety net", right?

Copy link
Contributor Author

@RogerKratz RogerKratz left a comment

Choose a reason for hiding this comment

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

Now when always checking if keyIndex is null before calling GetSortedKeyIndexes, it's clearer to do a single null check inside that method I think.

@fredericDelaporte
Copy link
Member

I was about to suggest writing a test for "collection case", but reading your last comment I understand this change was just "a safety net", right?

Yes. There is no ISession.Get equivalent for collections. But maybe, for example, some Merge cases could trigger the same issue. I do not know. Having a test case for collections would be better, if it is actually possible. But I am not sure it is.

@RogerKratz
Copy link
Contributor Author

Great! Thanks!

@maca88
Copy link
Contributor

maca88 commented Dec 6, 2018

@RogerKratz thanks for the provided test! It's my bad that I didn't tested this scenario.
@fredericDelaporte the provided fix is not correct as it can cause an endless loop where the entityKeys would be checked over and over again.
I've added additional checks in #1925 to prevent that and additional tests.
EDIT:
By changing only to a nullable parameter it seems that can also throw an IndexOutOfRangeException when batching is disabled.

@fredericDelaporte
Copy link
Member

Better add them here I think. It would have avoided to lose the improvements already done here, like generating the async tests for GH1920 tests (and some white-space cleanup in them).

@maca88
Copy link
Contributor

maca88 commented Dec 6, 2018

I've made a PR as I can't push directly to this one.

@fredericDelaporte
Copy link
Member

Indeed, you are not among NHibernate "members".

@fredericDelaporte
Copy link
Member

Replaced by #1925.

@fredericDelaporte fredericDelaporte removed this from the 5.2.1 milestone Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants