Skip to content

NullReferenceException in NHibernate.Type.TypeHelper #3735

@zrsio4

Description

@zrsio4

I'm staring at the source code and I can't figure out how a null reference exception can happen, but it's happening.
Here's the stack of the exception:

NullReferenceException: Object reference not set to an instance of an object. at NHibernate.Type.TypeHelper.FindDirty(StandardProperty[] properties, Object[] currentState, Object[] previousState, Boolean[][] includeColumns, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.FindDirty(Object[] currentState, Object[] previousState, Object entity, ISessionImplementor session) at [my code] 

The only property access I see in TypeHelper.FindDirty is properties.Length but the properties argument comes from entityMetamodel.Properties in AbstractEntityParser.FindDirty. entityMetamodel.Properties is assigned a non-null value in the EntityMetamodel constructor, so properties can't be null.
The results array starts null but is assigned a new array before index access.
The exception isn't happening in the Dirty(...) method so I'm ignoring that.

What else can cause a null ref exception?
I must be missing something,

The issue is not readily reproducible, but we have at least 3 instances of this happening.

Currently I'm using version 5.5.3, but I see the code in question hasn't changed in 5.6.0
.NET 8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions