Skip to content
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

NRE during FindAll #496

Closed
podkolzzzin opened this issue Feb 20, 2017 · 3 comments
Closed

NRE during FindAll #496

podkolzzzin opened this issue Feb 20, 2017 · 3 comments

Comments

@podkolzzzin
Copy link

podkolzzzin commented Feb 20, 2017

I have such code:

    private LiteCollection<BsonDocument> Sessions {
      get {
        return GetCollection(SessionCollection);
      }
    }
...
var sessions = Sessions.FindAll().ToList();

And once it accidently falls with NRE:

Stack:
at LiteDB.LiteEngine..ctor(IDiskService disk, String password, Nullable1 timeout, Int32 cacheSize, Logger log) at LiteDB.LiteDatabase.<>c__DisplayClass11_0.<.ctor>b__0() at LiteDB.LazyLoad1.get_Value()
at LiteDB.LiteCollection1.<Find>d__17.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)

I construct LiteDatabase class using the ctor with single argument(connectionString).

I investigated your code a bit, and the only suspicious place is:

var header = BasePage.ReadPage(_disk.ReadPage(0)) as HeaderPage;

P.S. Please reopen issue #363, I tested it on the latest sources and it still reproducing. Code sample is in the issue.

@mbdavid
Copy link
Owner

mbdavid commented Feb 21, 2017

Hi @podkolzzzin, I will take a look again on this. This line code that you marked is correct in this context.

@podkolzzzin
Copy link
Author

Hi, @mbdavid, you are probably right.
I just looked through the method and that's all.
As for me using of 'as' operator is appropriate only if null check exist, but in your case, you just use property, so probably direct cast would be more informative?

@mbdavid mbdavid added the bug label Feb 25, 2017
mbdavid added a commit that referenced this issue Feb 25, 2017
@lbnascimento
Copy link
Collaborator

Hi! With the objective of organizing our issues, we are closing old unsolved issues. Please check the latest version of LiteDB and open a new issue if your problem/question/suggestion still applies. Thanks!

github-actions bot pushed a commit to Reddevildragg-UPM-Forks/LiteDB that referenced this issue Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants