File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
java/ql/test/library-tests/dataflow/stream-collect Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .util .*;
2+ import java .util .stream .*;
3+
4+ public class A {
5+ String source () { return "source" ; }
6+
7+ void sink (Object o ) { }
8+
9+ void m () {
10+ String [] xs = new String [] { source () };
11+ Stream <String > s = Arrays .stream (xs );
12+
13+ sink (s .collect (Collectors .maxBy (null )).get ()); // $ hasValueFlow
14+ sink (s .collect (Collectors .minBy (null )).get ()); // $ hasValueFlow
15+ sink (s .collect (Collectors .toCollection (null )).iterator ().next ()); // $ hasValueFlow
16+ sink (s .collect (Collectors .toList ()).get (0 )); // $ hasValueFlow
17+ sink (s .collect (Collectors .toSet ()).iterator ().next ()); // $ hasValueFlow
18+ sink (s .collect (Collectors .toUnmodifiableList ()).get (0 )); // $ hasValueFlow
19+ sink (s .collect (Collectors .toUnmodifiableSet ()).iterator ().next ()); // $ hasValueFlow
20+
21+ // we don't attempt to cover weird things like this:
22+ sink (s .collect (true ? Collectors .toList () : null ).get (0 )); // $ MISSING: hasValueFlow
23+
24+ sink (s .collect (Collectors .joining ())); // $ hasTaintFlow
25+
26+ sink (s .collect (Collectors .groupingBy (null )).get (null ).get (0 )); // $ hasValueFlow
27+ sink (s .collect (Collectors .groupingByConcurrent (null )).get (null ).get (0 )); // $ hasValueFlow
28+ sink (s .collect (Collectors .partitioningBy (null )).get (null ).get (0 )); // $ hasValueFlow
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ import TestUtilities.InlineFlowTest
You can’t perform that action at this time.
0 commit comments