You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2014/04/02 00:10:16 UTC
[6/6] git commit: TAP5-2044: Misleading error message in logs when
accessing classpath assets
TAP5-2044: Misleading error message in logs when accessing classpath assets
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/3da4d99d
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/3da4d99d
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/3da4d99d
Branch: refs/heads/master
Commit: 3da4d99d66628fbde08c3fbd092194e63e03956a
Parents: 64d1618
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Tue Apr 1 14:52:53 2014 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Tue Apr 1 15:10:07 2014 -0700
----------------------------------------------------------------------
.../internal/services/AssetSourceImpl.java | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3da4d99d/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetSourceImpl.java
----------------------------------------------------------------------
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 2924d5b..cd9b4af 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
@@ -1,4 +1,4 @@
-// Copyright 2006-2013 The Apache Software Foundation
+// Copyright 2006-2014 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -158,9 +158,13 @@ public class AssetSourceImpl extends LockSupport implements AssetSource
// Ends with trailing slash:
String metaRoot = "META-INF/assets/" + toPathPrefix(resources.getComponentModel().getLibraryName());
- String metaPath = metaRoot + (restOfPath.startsWith("/")
- ? restOfPath.substring(1)
- : restOfPath);
+ String trimmedRestOfPath = restOfPath.startsWith("/") ? restOfPath.substring(1) : restOfPath;
+
+
+ // TAP5-2044: Some components specify a full path, starting with META-INF/assets/, and we should just trust them.
+ // The warning logic below is for compnents that specify a relative path. Our bad decisions come back to haunt us;
+ // Resource paths should always had a leading slash to differentiate relative from complete.
+ String metaPath = trimmedRestOfPath.startsWith("META-INF/assets/") ? trimmedRestOfPath : metaRoot + trimmedRestOfPath;
// Based on the path, metaResource is where it should exist in a 5.4 and beyond world ... unless the expanded
// path was a bit too full of ../ sequences, in which case the expanded path is not valid and we adjust the
@@ -236,6 +240,11 @@ public class AssetSourceImpl extends LockSupport implements AssetSource
return getAssetForResource(oldStyle);
}
+ /**
+ * Figure out the relative path, under /META-INF/assets/ for resources for a given library.
+ * The application library is the blank string and goes directly in /assets/; other libraries
+ * are like virtual folders within /assets/.
+ */
private String toPathPrefix(String libraryName)
{
return libraryName.equals("") ? "" : libraryName + "/";