How to reproduce:
- Create a File document
- Edit File document and increment version to 1.0
- Edit File document and increment version to 2.0
- Restore version 1.0
- Delete version 1.0
- Publish document --> NPE
Caused by: java.lang.NullPointerException at org.nuxeo.ecm.core.storage.sql.coremodel.SQLSession.createProxy(SQLSession.java:353) at org.nuxeo.ecm.core.api.AbstractSession.createProxyInternal(AbstractSession.java:2237) at org.nuxeo.ecm.core.api.AbstractSession.publishDocument(AbstractSession.java:2812) at org.nuxeo.ecm.core.api.AbstractSession.publishDocument(AbstractSession.java:2735) at org.nuxeo.ecm.platform.publisher.task.CoreProxyWithWorkflowFactory$DocumentPublisherUnrestricted.run(CoreProxyWithWorkflowFactory.java:441) at org.nuxeo.ecm.core.api.UnrestrictedSessionRunner.runUnrestricted(UnrestrictedSessionRunner.java:113) at org.nuxeo.ecm.platform.publisher.task.CoreProxyWithWorkflowFactory.publishDocument(CoreProxyWithWorkflowFactory.java:123) at org.nuxeo.ecm.platform.rendition.publisher.RenditionPublicationFactory.publishDocument(RenditionPublicationFactory.java:84) at org.nuxeo.ecm.platform.publisher.api.AbstractBasePublicationTree.publish(AbstractBasePublicationTree.java:126) at org.nuxeo.ecm.platform.publisher.impl.core.SectionPublicationTree.publish(SectionPublicationTree.java:132) at org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl.publish(PublisherServiceImpl.java:459) at org.nuxeo.ecm.platform.publisher.impl.service.AbstractRemotableTree.publish(AbstractRemotableTree.java:77) at org.nuxeo.ecm.platform.publisher.web.PublishActionsBean.doPublish(PublishActionsBean.java:223) at org.nuxeo.ecm.platform.publisher.web.PublishActionsBean.doPublish(PublishActionsBean.java:211)
The correct fix is to prevent version 1.0 from being deleted at all. It should not be deleted because the live document is checked in and has this version as its base version.