From 4465ba99b53633b6775f34c5c49c954708b21023 Mon Sep 17 00:00:00 2001 From: Karim Date: Sat, 28 Dec 2024 13:08:35 +0300 Subject: [PATCH] remove nulls from RsXslt --- src/main/java/org/takes/tk/TkClasspath.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/takes/tk/TkClasspath.java b/src/main/java/org/takes/tk/TkClasspath.java index 9c52fa7dd..cdc88a072 100644 --- a/src/main/java/org/takes/tk/TkClasspath.java +++ b/src/main/java/org/takes/tk/TkClasspath.java @@ -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; @@ -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 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()); } } ); } - }