Skip to content

Commit

Permalink
#1739 more null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 28, 2024
1 parent 2c9a15e commit 1fdb928
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/org/cactoos/io/ResourceOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,25 @@ public ResourceOf(final Text res,
@Override
@SuppressWarnings("PMD.CloseResource")
public InputStream stream() throws Exception {
if (this.path == null) {
throw new IllegalArgumentException(
"The \"path\" of the resource is NULL, which is not allowed"
);
}
if (this.loader == null) {
throw new IllegalArgumentException(
"The \"classloader\" is NULL, which is not allowed"
);
}
InputStream input = this.loader.getResourceAsStream(
this.path.asString()
);
if (input == null) {
if (this.fallback == null) {
throw new IllegalArgumentException(
"The \"fallback\" is NULL, which is not allowed"
);
}
input = new IoCheckedFunc<>(this.fallback)
.apply(this.path)
.stream();
Expand Down

0 comments on commit 1fdb928

Please sign in to comment.