Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319267 - [General] Do not use methods from EditorUtils
Summary: [General] Do not use methods from EditorUtils
Status: CLOSED INVALID
Alias: None
Product: Papyrus
Classification: Modeling
Component: Core (show other bugs)
Version: 0.7.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 0.7.0   Edit
Assignee: Cedric Dumoulin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 319002
  Show dependency tree
 
Reported: 2010-07-08 09:47 EDT by Cedric Dumoulin CLA
Modified: 2013-07-05 12:13 EDT (History)
1 user (show)

See Also:


Attachments
mylyn/context/zip (3.54 KB, application/octet-stream)
2010-07-08 09:51 EDT, Cedric Dumoulin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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