This is an automated email from the ASF dual-hosted git repository.

benw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git


The following commit(s) were added to refs/heads/master by this push:
     new ca1c40375 TAP5-2761: ResourceStreamer#streamResource documentation 
clarified and NPE fixed
ca1c40375 is described below

commit ca1c40375658a4da36a7792ae5c6778f6d275e12
Author: Ben Weidig <b...@netzgut.net>
AuthorDate: Sat Sep 2 12:55:04 2023 +0200

    TAP5-2761: ResourceStreamer#streamResource documentation clarified and NPE 
fixed
---
 .../org/apache/tapestry5/internal/services/ResourceStreamer.java   | 4 ++--
 .../apache/tapestry5/internal/services/ResourceStreamerImpl.java   | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResourceStreamer.java
 
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResourceStreamer.java
index 408901b66..a284565fa 100644
--- 
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResourceStreamer.java
+++ 
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResourceStreamer.java
@@ -58,7 +58,7 @@ public interface ResourceStreamer
      * @param resource
      *         to stream
      * @param providedChecksum
-     *         checksum from URL (or null to not validate against checksum, 
which is normal for modules)
+     *         checksum from URL (or null/blank to not validate against 
checksum, which is normal for modules)
      * @param options
      *         enable or disable certain features
      * @see StreamableResourceSource
@@ -73,7 +73,7 @@ public interface ResourceStreamer
      *         content to stream
      * @param providedChecksum
      *         checksum provided (in the URL) to validate against the 
{@linkplain 
org.apache.tapestry5.services.assets.StreamableResource#getChecksum()} actual 
checksum}
-     *         for the resource, may be blank to not validate against the 
checksum
+     *         for the resource, may be null/blank to not validate against the 
checksum
      * @param options
      *         enable or disable certain features
      * @return true if the request was handled (even if sending a {@link 
HttpServletResponse#SC_NOT_MODIFIED} response),
diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResourceStreamerImpl.java
 
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResourceStreamerImpl.java
index 51f6122e3..363c0b71c 100644
--- 
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResourceStreamerImpl.java
+++ 
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResourceStreamerImpl.java
@@ -92,6 +92,7 @@ public class ResourceStreamerImpl implements ResourceStreamer
         this.contextAssetFactory = contextAssetFactory;
     }
 
+    @Override
     public boolean streamResource(final Resource resource, final String 
providedChecksum, final Set<Options> options) throws IOException
     {
         if (!resource.exists())
@@ -103,7 +104,7 @@ public class ResourceStreamerImpl implements 
ResourceStreamer
             return true;
         }
 
-        final boolean compress = providedChecksum.startsWith("z");
+        final boolean compress = providedChecksum != null && 
providedChecksum.startsWith("z");
 
         return tracker.perform("Streaming " + resource + (compress ? " 
(compressed)" : ""), new IOOperation<Boolean>()
         {
@@ -120,6 +121,7 @@ public class ResourceStreamerImpl implements 
ResourceStreamer
         });
     }
 
+    @Override
     public boolean streamResource(StreamableResource streamable, String 
providedChecksum, Set<Options> options) throws IOException
     {
         return streamResource(null, streamable, providedChecksum, options);
@@ -128,12 +130,11 @@ public class ResourceStreamerImpl implements 
ResourceStreamer
     public boolean streamResource(Resource resource, StreamableResource 
streamable, String providedChecksum, Set<Options> options) throws IOException
     {
         assert streamable != null;
-        assert providedChecksum != null;
         assert options != null;
 
         String actualChecksum = streamable.getChecksum();
 
-        if (providedChecksum.length() > 0 && 
!providedChecksum.equals(actualChecksum))
+        if (providedChecksum != null && !providedChecksum.isEmpty() && 
!providedChecksum.equals(actualChecksum))
         {
             
             // TAP5-2185: Trying to find the wrongly-checksummed resource in 
the classpath and context,

Reply via email to