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
 

In this class diagram you can see the abstract base class doesn't have (nor requires) any of it's own attributes. The FieldManager class could have been an interface apart from the fact that:
  • we wanted all classes in this hierarchy to be stored in a single database table
  • we plan to add some stats attributes later and these would definitely go into this base class



In DN 5.1.6 we get the following exception:

java.lang.IllegalArgumentException: argment is null
at com.sas.framework.filemgr.FileManager.dnProvideFields(FileManager.java)
at org.datanucleus.state.StateManagerImpl.provideFields(StateManagerImpl.java:2510)
at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.checkForSchemaUpdatesForFieldsOfObject(RDBMSPersistenceHandler.java:667)
at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertObject(RDBMSPersistenceHandler.java:118)
at org.datanucleus.state.StateManagerImpl.internalMakePersistent(StateManagerImpl.java:4535)
at org.datanucleus.state.StateManagerImpl.flush(StateManagerImpl.java:5735)
at org.datanucleus.store.rdbms.mapping.java.PersistableMapping.setObjectAsValue(PersistableMapping.java:490)
at org.datanucleus.store.rdbms.mapping.java.PersistableMapping.setObject(PersistableMapping.java:366)
at org.datanucleus.store.rdbms.fieldmanager.ParameterSetter.storeObjectField(ParameterSetter.java:191)
at org.datanucleus.state.StateManagerImpl.providedObjectField(StateManagerImpl.java:1823)

The DN 5 StateManagementImpl class is passing a null fieldNumbers array to the method: com.sas.framework.filemgr.FileManager.dnProvideFields, a generated method added during byte code enhancement.

           currFM = fm;
            try
            {
                // This will respond by calling this.providedXXXFields() with the value of the field
                myPC.dnProvideFields(fieldNumbers);       <------ fieldNumbers array is null because this base class has no attributes - which should be fine
            }
            finally
            {
                currFM = prevFM;
            }

The call is fine, however the problem is in the generated code in the PC's dnProvideFields method. It may not be handling the case where it passed in a fieldNumbers array which is null, however null seems like a valid case if the class has no attributes.

By adding an "int dummy" attribute to the base class the issue goes away which indicates that the issue is related to having no attributes in a base class.

Where would we find the code that is responsible for generating the dnProvideFields method in the DN code base?

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