This is an automated email from the ASF dual-hosted git repository.
thiagohp 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 c9969fd TAP5-2656: CSS URL rewriting still throws exceptions
c9969fd is described below
commit c9969fd155be62f626da99a79a8f5ecd202cc232
Author: Thiago H. de Paula Figueiredo
AuthorDate: Wed Dec 30 15:55:39 2020 -0300
TAP5-2656: CSS URL rewriting still throws exceptions
for non-existing files even when configured to ignore them.
---
.../internal/services/AssetSourceImpl.java | 3 +-
.../internal/services/assets/CSSURLRewriter.java | 13 +-
.../tapestry5/services/AssetNotFoundException.java | 51 ++
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetSourceImpl.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetSourceImpl.java
index 0c6b391..966e2e2 100644
---
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetSourceImpl.java
+++
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetSourceImpl.java
@@ -29,6 +29,7 @@ import org.apache.tapestry5.ioc.internal.util.InternalUtils;
import org.apache.tapestry5.ioc.services.SymbolSource;
import org.apache.tapestry5.ioc.services.ThreadLocale;
import org.apache.tapestry5.services.AssetFactory;
+import org.apache.tapestry5.services.AssetNotFoundException;
import org.apache.tapestry5.services.AssetSource;
import org.slf4j.Logger;
@@ -387,7 +388,7 @@ public class AssetSourceImpl extends LockSupport implements
AssetSource
if (localized == null || !localized.exists())
{
-throw new RuntimeException(String.format("Unable to locate asset
'%s' (the file does not exist).", unlocalized));
+throw new AssetNotFoundException(String.format("Unable to locate
asset '%s' (the file does not exist).", unlocalized), unlocalized);
}
return getAssetForResource(localized);
diff --git
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
index 46313ed..e84e230 100644
---
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
+++
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
@@ -18,6 +18,7 @@ import org.apache.tapestry5.commons.Resource;
import org.apache.tapestry5.http.ContentType;
import org.apache.tapestry5.ioc.IOOperation;
import org.apache.tapestry5.ioc.OperationTracker;
+import org.apache.tapestry5.services.AssetNotFoundException;
import org.apache.tapestry5.services.AssetSource;
import org.apache.tapestry5.services.assets.*;
import org.slf4j.Logger;
@@ -174,7 +175,17 @@ public class CSSURLRewriter extends DelegatingSRS
url = url.substring(6);
}
-Asset asset = assetSource.getAsset(baseResource, url, null);
+Asset asset;
+
+// TAP5-2656
+try
+{
+asset = assetSource.getAsset(baseResource, url, null);
+}
+catch (AssetNotFoundException e)
+{
+asset = null;
+}
if (asset != null)
{
diff --git
a/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetNotFoundException.java
b/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetNotFoundException.java
new file mode 100644
index 000..2df60ba
--- /dev/null
+++
b/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetNotFoundException.java
@@ -0,0 +1,51 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.tapestry5.services;
+
+import org.apache.tapestry5.commons.Resource;
+
+/**
+ * Class that represents the exception of an asset not being found.
+ */
+public class AssetNotFoundException extends RuntimeException {
+
+private static final long serialVersionUID = 1L;
+
+final private Resource resource;
+
+/**
+ * {@inheritDoc}
+ */
+public AssetNotFoundException(String message) {
+super(message);
+resource = null;
+}
+
+/**
+ * Constructs an exception with