| Summary: | [Xtend] Flattening null entries leads to a NullPointerException | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Oliver L <oliver.libutzki> | ||||
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> | ||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | sebastian.zarnekow | ||||
| Version: | 2.2.0 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Oliver L
Created attachment 208308 [details]
Xtend class
Works as defined:
/**
* [..]
* The methods of the returned iterable may throw {@code NullPointerException} if any of the input iterators are null.
* [..]
*/
public static final <T> Iterable<T> flatten(Iterable<? extends Iterable<? extends T>> inputs) {
return Iterables.concat(inputs);
}
Btw: The NPE was thrown with 2.0.1, too. package org.xtext.example.mydsl
import java.util.ArrayList
import java.util.List
class Sample {
List<Sample> children
def test() {
val parents = new ArrayList<Sample>()
val parent1 = new Sample()
parent1.children = newArrayList(new Sample(), new Sample())
parents += new Sample()
val allChildren = parents.map(parent | parent.children).flatten
val size = allChildren.size
println("Size: " + size)
}
}
package org.xtext.example.mydsl;
public class Main {
public static void main(String[] args) {
new Sample().test();
}
}
Exception in thread "main" java.lang.NullPointerException
at com.google.common.collect.Iterables$3.apply(Iterables.java:422)
at com.google.common.collect.Iterables$3.apply(Iterables.java:420)
at com.google.common.collect.Iterators$8.next(Iterators.java:697)
at com.google.common.collect.Iterators$5.hasNext(Iterators.java:505)
at com.google.common.collect.Iterators.size(Iterators.java:122)
at com.google.common.collect.Iterables.size(Iterables.java:73)
at org.eclipse.xtext.xbase.lib.IterableExtensions.size(IterableExtensions.java:473)
at org.xtext.example.mydsl.Sample.test(Sample.java:39)
Sorry, I have to admit I didn't execute this test case with 2.0.1 as I don't have such an environment available at the moment. I just know that I didn't get this NullPointerException before updating from 2.0.1 to 2.2.. Obviously the flatten implementation has not changed but the way the Iterable is filled... anyway I have to do some further investigations why there are null values in 2.2. |