Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-23953

NPE when saving list property with null first

    XMLWordPrintable

    Details

      Description

      1. When saving a document, one might get the following stack trace:
        Caused by: java.lang.NullPointerException
        at org.nuxeo.ecm.core.storage.BaseDocument.writeComplexProperty(BaseDocument.java:814)
        at org.nuxeo.ecm.core.storage.BaseDocument.writeComplexProperty(BaseDocument.java:748)
        at org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocumentLive.writeDocumentPart(SQLDocumentLive.java:176)
        at org.nuxeo.ecm.core.api.DocumentModelFactory.writeDocumentModel(DocumentModelFactory.java:236)
        at org.nuxeo.ecm.core.api.AbstractSession.writeModel(AbstractSession.java:366)
        at org.nuxeo.ecm.core.api.AbstractSession.saveDocument(AbstractSession.java:1529)
        at com.nuxeo.pleiade.diffusion.web.mail.MailActionsBean.saveCurrentEmail(MailActionsBean.java:352)
        
      2. This is located here in the BaseDocument class:
                                if (list.isEmpty()) {
                                    array = new Object[0];
                                } else {
                                    // use properly-typed array, useful for mem backend that doesn't re-convert all types
                                    Class<?> klass = list.get(0).getClass();
                                    array = (Object[]) Array.newInstance(klass, list.size());
                                }
        

        list.get(0) is not tested for nullity.

      3. Just below another piece of code does it though:
                                    Class<?> klass = Object.class;
                                    for (Object o : ar) {
                                        if (o != null) {
                                            klass = o.getClass();
                                            break;
                                        }
                                    }
      4. The same issue is present from 7.10 to master.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours
                  2h