TAP5-2761: ResourceStreamer#streamResource documentation clarified and NPE fixed
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 408901b..a284565 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 @@
* @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 @@
* 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 51f6122..363c0b7 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 @@
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 @@
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 @@
});
}
+ @Override
public boolean streamResource(StreamableResource streamable, String providedChecksum, Set<Options> options) throws IOException
{
return streamResource(null, streamable, providedChecksum, options);
@@ -128,12 +130,11 @@
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,