Bug 484186 - [AQL] NPE on AQL completion
Summary: [AQL] NPE on AQL completion
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 3.1.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.0.0M7   Edit
Assignee: Cedric Brun CLA
QA Contact: Florian Barbin CLA
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2015-12-11 05:51 EST by Esteban DUGUEPEROUX CLA
Modified: 2016-06-24 08:03 EDT (History)
3 users (show)

See Also:


Attachments
Project to reproduce (833 bytes, application/zip)
2015-12-11 05:58 EST, Esteban DUGUEPEROUX CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Esteban DUGUEPEROUX CLA 2015-12-11 05:51:03 EST
I get the following exception on AQL completion :

Caused by: java.lang.NullPointerException
	at java.util.ComparableTimSort.countRunAndMakeAscending(ComparableTimSort.java:291)
	at java.util.ComparableTimSort.sort(ComparableTimSort.java:157)
	at java.util.ComparableTimSort.sort(ComparableTimSort.java:146)
	at java.util.Arrays.sort(Arrays.java:472)
	at java.util.Collections.sort(Collections.java:155)
	at org.eclipse.acceleo.query.parser.AstCompletor.getProposals(AstCompletor.java:90)
	at org.eclipse.acceleo.query.runtime.impl.QueryCompletionEngine.getCompletion(QueryCompletionEngine.java:73)
	at org.eclipse.sirius.common.acceleo.aql.ide.proposal.AQLProposalProvider.getProposals(AQLProposalProvider.java:102)
	at org.eclipse.sirius.common.acceleo.aql.ide.proposal.AQLProposalProvider.getProposals(AQLProposalProvider.java:76)
	at org.eclipse.sirius.common.tools.api.interpreter.CompoundInterpreter.getProposals(CompoundInterpreter.java:836)
	at org.eclipse.sirius.ui.tools.api.assist.TextContentProposalProvider.getProposals(TextContentProposalProvider.java:88)
	at org.eclipse.jface.fieldassist.ContentProposalAdapter.getProposals(ContentProposalAdapter.java:2057)
	at org.eclipse.jface.fieldassist.ContentProposalAdapter.access$10(ContentProposalAdapter.java:2043)
	at org.eclipse.jface.fieldassist.ContentProposalAdapter$ContentProposalPopup.recomputeProposals(ContentProposalAdapter.java:1018)
	at org.eclipse.jface.fieldassist.ContentProposalAdapter$ContentProposalPopup.access$14(ContentProposalAdapter.java:1017)
	at org.eclipse.jface.fieldassist.ContentProposalAdapter$ContentProposalPopup$5.run(ContentProposalAdapter.java:1045)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
	... 24 more
Comment 1 Esteban DUGUEPEROUX CLA 2015-12-11 05:58:27 EST
Created attachment 258604 [details]
Project to reproduce

Steps to reproduce:

1. Import the attached project
2. Open the odesign
3. Select the "Select Model Element Variable"
4. Through properties view, in "Candidates Expression", type "Ctrl+Space" to have completion and type "aql:" and "Esc" => KO the exception occurs
In addition the UI is not very responsive on "aql:" writing.
Comment 2 Esteban DUGUEPEROUX CLA 2015-12-11 07:51:23 EST
I have this bug with Sirius 3.1.3.201511201007 and AQL 4.0.0.201510121214 but I reproduce also on Sirius master at this time.
Comment 3 Cedric Brun CLA 2016-01-12 11:45:06 EST
I could reproduce with the given project and Sirius/AQL master.

The root cause is that the "Select Model Element Variable" has no name and returns "null" for it. Sirius does not ignore this and try to declare a variable having "null" as a name (which is quite obviously illegal). 
In the end AQL fails because of null keys in the variable definition maps.
Comment 4 Eclipse Genie CLA 2016-01-12 11:51:08 EST
New Gerrit change created: https://git.eclipse.org/r/64156
Comment 6 Pierre-Charles David CLA 2016-01-20 05:07:37 EST
Is this fixed by the merged commit? If so, please either add an non-regression test or mark the ticket as FIXED but with the "needtest" tag in the whiteboard field.
Comment 7 Pierre-Charles David CLA 2016-03-09 11:30:59 EST
Moving to M6, as this is probably fixed but the status is not clear.
Comment 8 Cedric Brun CLA 2016-03-21 05:50:52 EDT
Indeed it is fixed.

This is not specific to AQL (hence the fix is not), a variable with a "null" name would have ended up in the calls to the interpreters validation/completion API, leading to a NPE. 

Adding the "needtest" tag by default, I test should not be too hard to add but on the other hand the scenario is a variable wich has no name (and that, IMO, should probably be an invalid VSM. I just checked and it is not the case right now.

I'd like to have another opinion on wheter we should spend more time in adding the test or making sure the metamodel consider a null variable name an error...
Comment 9 Eclipse Genie CLA 2016-03-25 10:56:45 EDT
New Gerrit change created: https://git.eclipse.org/r/69325
Comment 10 Pierre-Charles David CLA 2016-03-25 10:57:58 EDT
(In reply to Cedric Brun from comment #8)
> Indeed it is fixed.
> 
> This is not specific to AQL (hence the fix is not), a variable with a "null"
> name would have ended up in the calls to the interpreters
> validation/completion API, leading to a NPE. 
> 
> Adding the "needtest" tag by default, I test should not be too hard to add
> but on the other hand the scenario is a variable wich has no name (and that,
> IMO, should probably be an invalid VSM. I just checked and it is not the
> case right now.
> 
> I'd like to have another opinion on wheter we should spend more time in
> adding the test or making sure the metamodel consider a null variable name
> an error...

https://git.eclipse.org/r/69325 is a first attempt to add the necessary validation rule. It looks like VSMValidationTest would be the automated test to complete to check for this.
Comment 12 Pierre-Charles David CLA 2016-04-07 03:36:59 EDT
Closing, as commit 3866ea64849aa14b93bf89a875d3214436dbd415 adds a validation rule about empty/blank variable names and the associated test.
Comment 13 Florian Barbin CLA 2016-05-24 10:37:02 EDT
Verified on Sirius 4.0.0.RC1
Comment 14 Pierre-Charles David CLA 2016-06-24 08:03:34 EDT
Available in Sirius 4.0.0.