NPE While creating SequenceFlow between events after Mars.2 update [message #1726110] |
Wed, 09 March 2016 12:16  |
Eclipse User |
|
|
|
Hello Colleagues,
We have an use case where in we create an StartEvent connected to EndEvent via SequenceFlow under an Participant when this custom shape is created.
Following is the sample code which was getting used for achieving the same and it was working fine until Mars.1 update from Eclipse BPMN. Unfortunately this seems to be broken after updates from Mars.2
private void addEvents(Participant createdParticipant) {
CreateContext createContext2 = new CreateContext();
final ContainerShape pictogramElementForBusinessObject = (ContainerShape) getFeatureProvider().getPictogramElementForBusinessObject(createdParticipant);
createContext2.setTargetContainer(pictogramElementForBusinessObject);
final int yCoordinateForEvent = createContext2.getY() + pictogramElementForBusinessObject.getGraphicsAlgorithm().getHeight() / 2 - 15;
createContext2.setLocation(createContext2.getX() + 25, yCoordinateForEvent);
final Object[] startEvent = new StartEventFeatureContainer().getCreateFeature(getFeatureProvider()).create(createContext2);
createContext2.setLocation(createContext2.getX() + pictogramElementForBusinessObject.getGraphicsAlgorithm().getWidth() - 75, yCoordinateForEvent);
final Object[] endEvent = new EndEventFeatureContainer().getCreateFeature(getFeatureProvider()).create(createContext2);
CreateConnectionContext createConnectionContext = new CreateConnectionContext();
createConnectionContext.setSourcePictogramElement(getFeatureProvider().getPictogramElementForBusinessObject((EObject) startEvent[0]));
createConnectionContext.setTargetPictogramElement(getFeatureProvider().getPictogramElementForBusinessObject((EObject) endEvent[0]));
new SequenceFlowFeatureContainer().getCreateConnectionFeature(getFeatureProvider()).create(createConnectionContext);
}
While trying to debug further for the root cause of the problem i see that when CreateConnectionFeature is trying to create the business object for sequence flow the eResource value for source pictogramelement (StartEvent in this case ) is still 'null' hence it's failing with NullPointerException.
Ideally after create has been called for StartEvent/EndEvent via createfeature then this value shouldn't be null.
Another point when it's checked
((org.eclipse.bpmn2.StartEvent)(EObject) startEvent[0]).eResource()
ofc the value is returned 'null' but if you try to fetch the eResource for ex. as following then value is not 'null'.
Resource startEventResource = ExtendedPropertiesAdapter.getResource((EObject) startEvent[0]);
Not sure why AbstractBpmn2CreateConnection feature does not use fallback mechanism for finding eReource when it's not available to the BusinessObject directly.
StackTrace
java.lang.NullPointerException
at org.eclipse.bpmn2.modeler.core.adapters.ExtendedPropertiesAdapter.adapt(ExtendedPropertiesAdapter.java:186)
at org.eclipse.bpmn2.modeler.core.model.Bpmn2ModelerFactory.createObject(Bpmn2ModelerFactory.java:344)
at org.eclipse.bpmn2.modeler.core.model.Bpmn2ModelerFactory.createObject(Bpmn2ModelerFactory.java:337)
at org.eclipse.bpmn2.modeler.core.features.AbstractBpmn2CreateConnectionFeature.createBusinessObject(AbstractBpmn2CreateConnectionFeature.java:255)
at org.eclipse.bpmn2.modeler.core.features.flow.AbstractCreateFlowFeature.createBusinessObject(AbstractCreateFlowFeature.java:164)
at org.eclipse.bpmn2.modeler.core.features.flow.AbstractCreateFlowFeature.create(AbstractCreateFlowFeature.java:90)
at org.eclipse.bpmn2.modeler.ui.features.flow.SequenceFlowFeatureContainer$CreateSequenceFlowFeature.create(SequenceFlowFeatureContainer.java:239)
Could you please suggest of anything is wrong here in the sequence of calls, to me it seems to be a regression since same code was working fine so far untill Mars.1.
--
Thanks and Regards,
Bhuvan Mehta
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05131 seconds