forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrivateFlowViaPublicInterface.java
More file actions
61 lines (44 loc) · 1.43 KB
/
Copy pathPrivateFlowViaPublicInterface.java
File metadata and controls
61 lines (44 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package p;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class PrivateFlowViaPublicInterface {
static class RandomPojo {
public File someFile = new File("someFile");
}
public static interface SPI {
OutputStream openStream() throws IOException;
default OutputStream openStreamNone() throws IOException {
return null;
};
}
private static final class PrivateImplWithSink implements SPI {
private File file;
public PrivateImplWithSink(File file) {
this.file = file;
}
@Override
public OutputStream openStream() throws IOException {
return new FileOutputStream(file);
}
}
private static final class PrivateImplWithRandomField implements SPI {
public PrivateImplWithRandomField(File file) {
}
@Override
public OutputStream openStream() throws IOException {
return null;
}
@Override
public OutputStream openStreamNone() throws IOException {
return new FileOutputStream(new RandomPojo().someFile);
}
}
public static SPI createAnSPI(File file) {
return new PrivateImplWithSink(file);
}
public static SPI createAnSPIWithoutTrackingFile(File file) {
return new PrivateImplWithRandomField(file);
}
}