Fix Close stream after materialisation in ListAssert
Streams may carry resources which require closing such as
java.nio.file.Files#lines(java.nio.file.Path).
@@ -226,7 +226,10 @@ public class ListAssert<ELEMENT> extends
}
private List<ELEMENT> initList() {
- if (list == null) list = Lists.newArrayList(stream.iterator());
+ if (list == null) {
+ list = Lists.newArrayList(stream.iterator());
+ stream.close();
+ }
return list;
}
