Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345870 - AbstractFeatureProvider.link(PictogramElement pictogramElement, Object[] businessObjects) should check Business Object's eResource is not null
Summary: AbstractFeatureProvider.link(PictogramElement pictogramElement, Object[] busi...
Status: CLOSED FIXED
Alias: None
Product: Graphiti
Classification: Modeling
Component: Core (show other bugs)
Version: 0.8.0   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 0.8.0   Edit
Assignee: Tim Kaiser CLA
QA Contact:
URL:
Whiteboard: Indigo RC1 theme_bugs
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-16 00:51 EDT by M CLA
Modified: 2011-06-24 08:45 EDT (History)
1 user (show)

See Also:
tim.kaiser: indigo+


Attachments
mylyn/context/zip (15.12 KB, application/octet-stream)
2011-05-17 08:09 EDT, Tim Kaiser CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description M CLA 2011-05-16 00:51:24 EDT
Build Identifier: 20110319-2305

AbstractFeatureProvider.link(PictogramElement pictogramElement, Object[] businessObjects) should check that Business Object's .eResource() and .getResourceSet() are not null before using.

If something is null, throw a descriptive exception (message e.g.: The business object's resource/resourceset must be set before it is linked to the pictogram.)

Whenever I forget to set the resource, I spend a few minutes tracking down a generic NullPointerException, only to find that this is the issue.

Reproducible: Always

Steps to Reproduce:
1. In a AbstractCreateConnectionFeature in Graphiti using emf model
2. create a new emf business model object, do not link it to the resourceset
3. in create method override, call IFeatureProvider.addIfPossible
4. NullPointerException occurs:

!ENTRY org.eclipse.graphiti 4 0 2011-05-16 14:28:39.462
!MESSAGE CommandExec.executeCommand() java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
at org.eclipse.graphiti.features.impl.AbstractFeatureProvider.link(AbstractFeatureProvider.java:639)
	at org.eclipse.graphiti.features.impl.AbstractFeature.link(AbstractFeature.java:205)
	at org.eclipse.graphiti.features.impl.AbstractFeature.link(AbstractFeature.java:193)
	at mypackage.AddConnectionFeature.add(AddConnectionFeature.java:43)
	at org.eclipse.graphiti.internal.command.AddFeatureCommandWithContext.execute(AddFeatureCommandWithContext.java:76)
	at org.eclipse.graphiti.internal.command.GFPreparableCommand.doExecute(GFPreparableCommand.java:37)
	at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)
	at org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl.execute(GFWorkspaceCommandStackImpl.java:52)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
	at org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl.execute(GFWorkspaceCommandStackImpl.java:39)
	at org.eclipse.graphiti.internal.command.CommandExec.executeCommand(CommandExec.java:74)
	at org.eclipse.graphiti.features.impl.AbstractFeatureProvider.addIfPossible(AbstractFeatureProvider.java:338)
	at mypackage.CreateConnectionFeature.create(CreateConnectionFeature.java:86)
Comment 1 Tim Kaiser CLA 2011-05-17 08:09:53 EDT
Created attachment 195842 [details]
mylyn/context/zip
Comment 2 Tim Kaiser CLA 2011-05-17 08:13:58 EDT
eclipse runtime assertions added, runtime exception with descriptive message will be thrown
Comment 3 Michael Wenz CLA 2011-06-24 08:45:04 EDT
Part of Graphiti Indigo 0.8.0