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

Bug 319267

Summary: [General] Do not use methods from EditorUtils
Product: [Modeling] Papyrus Reporter: Cedric Dumoulin <cedric.dumoulin>
Component: CoreAssignee: Cedric Dumoulin <cedric.dumoulin>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: mdt-papyrus-inbox
Version: 0.7.0   
Target Milestone: 0.7.0   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 319002    
Attachments:
Description Flags
mylyn/context/zip none

Description Cedric Dumoulin CLA 2010-07-08 09:47:33 EDT
A lot of methods in org.eclipse.papyrus.core.utils.EditorUtils can return null if they don't find what they are designed for.
This is documented, but the null value is rarely tested in the actual code. This can throw a NPE later in the code.
Especially, this methods relies on the fact that there is an Eclipse active editor, which is not always the case.
Normally, only code relying on an active editor, like ui actions, should use these methods.

These methods are generally used to get the ServiceRegistry, or a Service like the TransactionalEditingDomain.

A recipe describing how to safely get the ServiceRegistry or a service has been added in 
svn+ssh://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments/cookbook/PapyrusCookBook.odt

An action should be taken asap to remove calls to the methods in EditorUtils, has there is potential NPE. The replacement can't be systematic, has it depends on the context of the call.
Comment 1 Cedric Dumoulin CLA 2010-07-08 09:51:51 EDT
Created attachment 173771 [details]
mylyn/context/zip

The classes to use instead of EditorUtils
Comment 2 Camille Letavernier CLA 2013-07-05 12:13:09 EDT
I close this task which is too generic