Skip to content

Commit 1fdb928

Browse files
committed
#1739 more null checks
1 parent 2c9a15e commit 1fdb928

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/org/cactoos/io/ResourceOf.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,25 @@ public ResourceOf(final Text res,
215215
@Override
216216
@SuppressWarnings("PMD.CloseResource")
217217
public InputStream stream() throws Exception {
218+
if (this.path == null) {
219+
throw new IllegalArgumentException(
220+
"The \"path\" of the resource is NULL, which is not allowed"
221+
);
222+
}
223+
if (this.loader == null) {
224+
throw new IllegalArgumentException(
225+
"The \"classloader\" is NULL, which is not allowed"
226+
);
227+
}
218228
InputStream input = this.loader.getResourceAsStream(
219229
this.path.asString()
220230
);
221231
if (input == null) {
232+
if (this.fallback == null) {
233+
throw new IllegalArgumentException(
234+
"The \"fallback\" is NULL, which is not allowed"
235+
);
236+
}
222237
input = new IoCheckedFunc<>(this.fallback)
223238
.apply(this.path)
224239
.stream();

0 commit comments

Comments
 (0)