Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 322779

Summary: NullPointerException after deleting a resource
Product: [Modeling] EMF Reporter: Eike Stepper <stepper>
Component: cdo.coreAssignee: Eike Stepper <stepper>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 CC: lindeman1966, Michal.Tkacz, rumburak.eclipse
Version: 4.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch v1 none

Description Eike Stepper CLA 2010-08-16 08:05:19 EDT
Cloned from: 322754: NullPointerException  after deleting a resource
https://bugs.eclipse.org/bugs/show_bug.cgi?id=322754

When trying to upgrade to CDO 3, I have run into a NullPointerException after deleting a resource (stack trace below). The delete is done by

resource.delete(null);

When commiting this change I get the exception. The variable "view" is null when the exception occurs. 

This exception never happened with CDO 2.

 java.lang.NullPointerException
	at org.eclipse.emf.internal.cdo.util.FSMUtil.adapt(FSMUtil.java:108)
	at org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl.getURIFragment(CDOResourceImpl.java:557)
	at org.eclipse.emf.ecore.util.EcoreUtil.getURI(EcoreUtil.java:2901)
	at org.eclipse.emf.internal.cdo.view.CDOViewImpl.provideCDOID(CDOViewImpl.java:1196)
	at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.provideCDOID(CDOTransactionImpl.java:1788)
	at org.eclipse.emf.cdo.internal.common.revision.delta.CDOSingleValueFeatureDeltaImpl.writeValue(CDOSingleValueFeatureDeltaImpl.java:86)
	at org.eclipse.emf.cdo.internal.common.revision.delta.CDOSingleValueFeatureDeltaImpl.write(CDOSingleValueFeatureDeltaImpl.java:62)
	at org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl.writeCDOFeatureDelta(CDODataOutputImpl.java:385)
	at org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl.write(CDORevisionDeltaImpl.java:158)
	at org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl.writeCDORevisionDelta(CDODataOutputImpl.java:380)
	at org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest.requestingCommit(CommitTransactionRequest.java:190)
	at org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest.requesting(CommitTransactionRequest.java:141)
	at org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest.requesting(CommitTransactionRequest.java:116)
	at org.eclipse.net4j.signal.RequestWithMonitoring.requesting(RequestWithMonitoring.java:163)
	at org.eclipse.net4j.signal.RequestWithConfirmation.doExtendedOutput(RequestWithConfirmation.java:117)
	at org.eclipse.net4j.signal.Signal.doOutput(Signal.java:285)
	at org.eclipse.net4j.signal.RequestWithConfirmation.doExecute(RequestWithConfirmation.java:102)
	at org.eclipse.net4j.signal.RequestWithMonitoring.doExecute(RequestWithMonitoring.java:233)
	at org.eclipse.net4j.signal.SignalActor.execute(SignalActor.java:66)
	at org.eclipse.net4j.signal.Signal.runSync(Signal.java:240)
	at org.eclipse.net4j.signal.SignalProtocol.startSignal(SignalProtocol.java:462)
	at org.eclipse.net4j.signal.RequestWithConfirmation.doSend(RequestWithConfirmation.java:87)
	at org.eclipse.net4j.signal.RequestWithConfirmation.send(RequestWithConfirmation.java:73)
	at org.eclipse.net4j.signal.RequestWithMonitoring.send(RequestWithMonitoring.java:108)
	at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol.send(CDOClientProtocol.java:375)
	at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol.commitTransaction(CDOClientProtocol.java:258)
	at org.eclipse.emf.internal.cdo.transaction.CDOSingleTransactionStrategyImpl.commit(CDOSingleTransactionStrategyImpl.java:73)
	at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:906)
Comment 1 Eike Stepper CLA 2010-08-16 08:08:25 EDT
Added Bugzilla_322754_Test

Committed to HEAD
Comment 2 Michal Tkacz CLA 2010-10-18 09:35:01 EDT
Eike, any idea if this can be solved easily?
Comment 3 Eike Stepper CLA 2010-10-30 04:27:34 EDT
Finally I found out what seems to happen: You're deleting a resource but are still having some resources with objects that point to objects in the deleted resource. Please compare Bugzilla_322754_Test.testResourceDeleteWithDanglingReferences().

I'll attach a patch that makes this situation more obvious by throwing a DanglingReferenceException. The exception message (object is not contained in a resource" is not 100% correct, as the object is contained by a resource, but both the resource and the object are TRANSIENT.
Comment 4 Eike Stepper CLA 2010-10-30 04:28:04 EDT
Created attachment 182097 [details]
Patch v1
Comment 5 Eike Stepper CLA 2010-10-30 04:29:11 EDT
Committed to HEAD.

Please reopen if you think I've misunderstood or if you are able to propose a better solution.
Comment 6 Eike Stepper CLA 2011-06-23 03:39:48 EDT
Available in R20110608-1407