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

Bug 486732

Summary: Avoid NPE when when no location information is available
Product: z_Archived Reporter: Carsten Pfeiffer <carsten.pfeiffer>
Component: m2eAssignee: Project Inbox <m2e.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: fbricon
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
See Also: https://git.eclipse.org/r/65374
https://git.eclipse.org/c/m2e/m2e-core.git/commit/?id=dfd4dbbe643508f1866a5a14ce755298fcdceb4f
Whiteboard:

Description Carsten Pfeiffer CLA 2016-01-28 10:41:53 EST
m2e produces an NPE when no source location information is available for an element. This can happen e.g. when parent models are provided by an extension (e.g. the Maven Tiles extension).
Comment 1 Carsten Pfeiffer CLA 2016-01-28 10:49:41 EST
See https://git.eclipse.org/r/65374 for a fix.
Comment 2 Fred Bricon CLA 2016-01-28 11:16:39 EST
Thanks for the patch Carsten. Could you please also add a test case to https://github.com/tesla/m2e-core-tests?
Comment 3 Carsten Pfeiffer CLA 2016-01-29 11:43:27 EST
Unfortunately this is quite hard. The Maven tiles extension uses internal Maven API with the help of Groovy to add "virtual parent" models. These virtual models have no source file. 

Now when the build aborts due to a problem with the execution of a "virtual parent", m2e tries to find the source location of the cause, which fails of course (there is no source).

One could argue that this is a bug in the tiles extension, (using internal API to add models without source location), but it would also be nice if m2e would be graceful and not produce an NPE.
Comment 4 Fred Bricon CLA 2016-05-03 13:25:40 EDT
Ok fair enough. Given it's a simple null-check, I applied it anyway.

Thanks Carsten
Comment 5 Denis Roy CLA 2021-04-19 13:22:44 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/