Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [EEF] NPE when selecting to add a relation
| | | |
Re: [EEF] NPE when selecting to add a relation [message #657224 is a reply to message #657201] |
Wed, 02 March 2011 01:37 |
Alain Picard Messages: 266 Registered: July 2009 |
Senior Member |
|
|
On 3/1/2011 5:35 PM, Ed Merks wrote:
Ed,
The example is a simple modification of the model1.ecore from CDO again,
just with the offending Map$Entry removed.
I just found a very interesting thing. In
org.eclipse.emf.eef.runtime.ui.widgets.settings.AdvancedEEFE ditorContentProvider.getElements
we have:
public Object[] getElements(Object object) {
if (object instanceof EEFEditorSettings) {
EList<Resource> resources =
((EEFEditorSettings)object).getSource().eResource().getResou rceSet().getResources();
resources.retainAll(this.choiceOfValues);
return resources.toArray();
}
return super.getElements(object);
}
what happens is that if I click the + button on a widget implemented
with AdvancedReferencesTable when there is no reference content that
exist, the getElements() method is called a first time and there is no
error, but resources is set to an empty list. Then when it calls
resources.retainAll with an empty choice a values, the retainAll ends up
calling remove, which calls inverseRemove which ends with:
return resource.basicSetResourceSet(null, notifications); resetting the
Resourceset value to null.
Then on the following calls, the resourceset is null and voila, an NPE.
HTH,
Alain
> Alain,
>
> I imagine they'll likely need a test case for this if you want to report
> it as a bug. In the mean time, you could determine the URI of that
> resource, who's creating a resource URI, and why it's not created as
> part of a resource set. It's quite unusual to have "free floating"
> resources...
>
>
> Alain Picard wrote:
>> On 3/1/2011 11:01 AM, Ed Merks wrote:
>>> Alain,
>>>
>>> It's a little odd that you'd have a resource that isn't in a resource
>>> set. How does that happen?
>>
>> Not sure but it does. :)
>>
>> Alain
>>
>>>
>>>
>>> Alain Picard wrote:
>>>> I am getting an NPE when selecting to add a relation
>>>>
>>>> The stack trace is:
>>>> java.lang.NullPointerException at
>>>> org.eclipse.emf.eef.runtime.ui.widgets.settings.AdvancedEEFE ditorContentProvider.getElements(AdvancedEEFEditorContentPro vider.java:65)
>>>>
>>>>
>>>> org.eclipse.jface.viewers.StructuredViewer.getRawChildren(St ructuredViewer.java:989)
>>>>
>>>>
>>>> org.eclipse.jface.viewers.ColumnViewer.getRawChildren(Column Viewer.java:703)
>>>>
>>>>
>>>> org.eclipse.jface.viewers.AbstractTreeViewer.getRawChildren( AbstractTreeViewer.java:1332)
>>>>
>>>>
>>>> org.eclipse.jface.viewers.TreeViewer.getRawChildren(TreeView er.java:391)
>>>>
>>>>
>>>> which point to this line of code:
>>>> EList<Resource> resources =
>>>> ((EEFEditorSettings)object).getSource().eResource().getResou rceSet().getResources();
>>>>
>>>>
>>>>
>>>> and it happens because the getResourceSet() portion is returning null.
>>>>
>>>> If I create at least one entry matching the relation the error goes
>>>> away and I see the dialog allowing me to select from the Model
>>>> Resource or All Resource.
>>>>
>>>> Thanks
>>>> Alain
>>
|
|
|
Re: [EEF] NPE when selecting to add a relation [message #657234 is a reply to message #657224] |
Wed, 02 March 2011 03:59 |
Ed Merks Messages: 33107 Registered: July 2009 |
Senior Member |
|
|
Alain,
Comments below.
Alain Picard wrote:
> On 3/1/2011 5:35 PM, Ed Merks wrote:
> Ed,
>
> The example is a simple modification of the model1.ecore from CDO
> again, just with the offending Map$Entry removed.
>
> I just found a very interesting thing. In
> org.eclipse.emf.eef.runtime.ui.widgets.settings.AdvancedEEFE ditorContentProvider.getElements
> we have:
>
> public Object[] getElements(Object object) {
> if (object instanceof EEFEditorSettings) {
> EList<Resource> resources =
> ((EEFEditorSettings)object).getSource().eResource().getResou rceSet().getResources();
>
> resources.retainAll(this.choiceOfValues);
Modifying the resource set itself as part of producing a view for it
seems totally bad! This code should make a copy of the list of resources...
> return resources.toArray();
> }
> return super.getElements(object);
> }
> what happens is that if I click the + button on a widget implemented
> with AdvancedReferencesTable when there is no reference content that
> exist, the getElements() method is called a first time and there is no
> error, but resources is set to an empty list. Then when it calls
> resources.retainAll with an empty choice a values, the retainAll ends
> up calling remove, which calls inverseRemove which ends with:
> return resource.basicSetResourceSet(null, notifications); resetting
> the Resourceset value to null.
>
> Then on the following calls, the resourceset is null and voila, an NPE.
>
> HTH,
>
> Alain
>
>
>> Alain,
>>
>> I imagine they'll likely need a test case for this if you want to report
>> it as a bug. In the mean time, you could determine the URI of that
>> resource, who's creating a resource URI, and why it's not created as
>> part of a resource set. It's quite unusual to have "free floating"
>> resources...
>
>
>
>
>>
>>
>> Alain Picard wrote:
>>> On 3/1/2011 11:01 AM, Ed Merks wrote:
>>>> Alain,
>>>>
>>>> It's a little odd that you'd have a resource that isn't in a resource
>>>> set. How does that happen?
>>>
>>> Not sure but it does. :)
>>>
>>> Alain
>>>
>>>>
>>>>
>>>> Alain Picard wrote:
>>>>> I am getting an NPE when selecting to add a relation
>>>>>
>>>>> The stack trace is:
>>>>> java.lang.NullPointerException at
>>>>> org.eclipse.emf.eef.runtime.ui.widgets.settings.AdvancedEEFE ditorContentProvider.getElements(AdvancedEEFEditorContentPro vider.java:65)
>>>>>
>>>>>
>>>>>
>>>>> org.eclipse.jface.viewers.StructuredViewer.getRawChildren(St ructuredViewer.java:989)
>>>>>
>>>>>
>>>>>
>>>>> org.eclipse.jface.viewers.ColumnViewer.getRawChildren(Column Viewer.java:703)
>>>>>
>>>>>
>>>>>
>>>>> org.eclipse.jface.viewers.AbstractTreeViewer.getRawChildren( AbstractTreeViewer.java:1332)
>>>>>
>>>>>
>>>>>
>>>>> org.eclipse.jface.viewers.TreeViewer.getRawChildren(TreeView er.java:391)
>>>>>
>>>>>
>>>>>
>>>>> which point to this line of code:
>>>>> EList<Resource> resources =
>>>>> ((EEFEditorSettings)object).getSource().eResource().getResou rceSet().getResources();
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> and it happens because the getResourceSet() portion is returning
>>>>> null.
>>>>>
>>>>> If I create at least one entry matching the relation the error goes
>>>>> away and I see the dialog allowing me to select from the Model
>>>>> Resource or All Resource.
>>>>>
>>>>> Thanks
>>>>> Alain
>>>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: [EEF] NPE when selecting to add a relation [message #658194 is a reply to message #657234] |
Mon, 07 March 2011 11:21 |
Goulwen Le Fur Messages: 125 Registered: July 2009 |
Senior Member |
|
|
Hello,
It's an important bug. I fix it in the next EEF 0.9 RC.
Thanks,
--
Goulwen Le Fur - goulwen.lefur@obeo.fr
Le 02/03/2011 04:59, Ed Merks a écrit :
> Alain,
>
> Comments below.
>
> Alain Picard wrote:
>> On 3/1/2011 5:35 PM, Ed Merks wrote:
>> Ed,
>>
>> The example is a simple modification of the model1.ecore from CDO
>> again, just with the offending Map$Entry removed.
>>
>> I just found a very interesting thing. In
>> org.eclipse.emf.eef.runtime.ui.widgets.settings.AdvancedEEFE ditorContentProvider.getElements
>> we have:
>>
>> public Object[] getElements(Object object) {
>> if (object instanceof EEFEditorSettings) {
>> EList<Resource> resources =
>> ((EEFEditorSettings)object).getSource().eResource().getResou rceSet().getResources();
>>
>> resources.retainAll(this.choiceOfValues);
> Modifying the resource set itself as part of producing a view for it
> seems totally bad! This code should make a copy of the list of resources...
>> return resources.toArray();
>> }
>> return super.getElements(object);
>> }
>> what happens is that if I click the + button on a widget implemented
>> with AdvancedReferencesTable when there is no reference content that
>> exist, the getElements() method is called a first time and there is no
>> error, but resources is set to an empty list. Then when it calls
>> resources.retainAll with an empty choice a values, the retainAll ends
>> up calling remove, which calls inverseRemove which ends with:
>> return resource.basicSetResourceSet(null, notifications); resetting
>> the Resourceset value to null.
>>
>> Then on the following calls, the resourceset is null and voila, an NPE.
>>
>> HTH,
>>
>> Alain
>>
>>
>>> Alain,
>>>
>>> I imagine they'll likely need a test case for this if you want to report
>>> it as a bug. In the mean time, you could determine the URI of that
>>> resource, who's creating a resource URI, and why it's not created as
>>> part of a resource set. It's quite unusual to have "free floating"
>>> resources...
>>
>>
>>
>>
>>>
>>>
>>> Alain Picard wrote:
>>>> On 3/1/2011 11:01 AM, Ed Merks wrote:
>>>>> Alain,
>>>>>
>>>>> It's a little odd that you'd have a resource that isn't in a resource
>>>>> set. How does that happen?
>>>>
>>>> Not sure but it does. :)
>>>>
>>>> Alain
>>>>
>>>>>
>>>>>
>>>>> Alain Picard wrote:
>>>>>> I am getting an NPE when selecting to add a relation
>>>>>>
>>>>>> The stack trace is:
>>>>>> java.lang.NullPointerException at
>>>>>> org.eclipse.emf.eef.runtime.ui.widgets.settings.AdvancedEEFE ditorContentProvider.getElements(AdvancedEEFEditorContentPro vider.java:65)
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.eclipse.jface.viewers.StructuredViewer.getRawChildren(St ructuredViewer.java:989)
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.eclipse.jface.viewers.ColumnViewer.getRawChildren(Column Viewer.java:703)
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.eclipse.jface.viewers.AbstractTreeViewer.getRawChildren( AbstractTreeViewer.java:1332)
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.eclipse.jface.viewers.TreeViewer.getRawChildren(TreeView er.java:391)
>>>>>>
>>>>>>
>>>>>>
>>>>>> which point to this line of code:
>>>>>> EList<Resource> resources =
>>>>>> ((EEFEditorSettings)object).getSource().eResource().getResou rceSet().getResources();
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> and it happens because the getResourceSet() portion is returning
>>>>>> null.
>>>>>>
>>>>>> If I create at least one entry matching the relation the error goes
>>>>>> away and I see the dialog allowing me to select from the Model
>>>>>> Resource or All Resource.
>>>>>>
>>>>>> Thanks
>>>>>> Alain
>>>>
>>
|
|
|
Goto Forum:
Current Time: Tue Mar 19 09:03:39 GMT 2024
Powered by FUDForum. Page generated in 0.03654 seconds
|