Skip to content

Commit

Permalink
remove nulls from RsXslt
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartofanych committed Dec 28, 2024
1 parent 2f7bc6c commit 4465ba9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/org/takes/tk/TkClasspath.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.takes.Request;
import org.takes.Response;
import org.takes.Take;
import org.takes.misc.Opt;
import org.takes.rq.RqHref;
import org.takes.rs.RsWithBody;

Expand Down Expand Up @@ -91,18 +92,18 @@ public Response act(final Request request) throws IOException {
final String name = String.format(
"%s%s", prefix, new RqHref.Base(request).href().path()
);
final InputStream input = this.getClass()
.getResourceAsStream(name);
if (input == null) {
final Opt<InputStream> input = new Opt.Single<>(
this.getClass().getResourceAsStream(name)
);
if (!input.has()) {
throw new HttpException(
HttpURLConnection.HTTP_NOT_FOUND,
String.format("%s not found in classpath", name)
);
}
return new RsWithBody(input);
return new RsWithBody(input.get());
}
}
);
}

}

0 comments on commit 4465ba9

Please sign in to comment.