Re: Generated dnProvideFields method appears to not handle case where fieldNumbers array is null (i.e. class has no attributes) in DN 5.1.6


Page bloom
 
Edited

Passing an empty fieldNumbers native array does prevent the dnProvideFields method from throwing an IllegalArgumentException 

I can raise a pull request for a fix like this if you think it's reasonable:

StateManagementImpl.java lines 2507-2517 
 
            try
            {
+                // In case class has no attributes pass empty array instead of null
+                if (fieldNumbers == null)
+                    fieldNumbers = new int[0];
+
                // This will respond by calling this.providedXXXFields() with the value of the field
                myPC.dnProvideFields(fieldNumbers);
            }
            finally
            {
                currFM = prevFM;
            }

It is probably a simpler fix than changing the generated dnProvideFields method but making the change there might be more "correct" - and it might even reduce the size of the generated method, possibly speeding up enhancement of large persistent models (but maybe not significantly)

Join main@datanucleus.groups.io to automatically receive all group messages.