nhibernate-core icon indicating copy to clipboard operation
nhibernate-core copied to clipboard

NullReferenceException in NHibernate.Type.TypeHelper

Open zrsio4 opened this issue 1 week ago • 1 comments

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.

zrsio4 avatar Dec 08 '25 22:12 zrsio4