You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2015/11/12 10:35:32 UTC

[1/2] tapestry-5 git commit: make use of the extracted variable

Repository: tapestry-5
Updated Branches:
  refs/heads/master 15ad465f4 -> c61335a15


make use of the extracted variable


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/f0436696
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/f0436696
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/f0436696

Branch: refs/heads/master
Commit: f04366962ae5727e5fda6b82181bcf28cca75bed
Parents: 15ad465
Author: Jochen Kemnade <jo...@eddyson.de>
Authored: Thu Nov 12 09:31:44 2015 +0100
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Thu Nov 12 09:31:44 2015 +0100

----------------------------------------------------------------------
 .../org/apache/tapestry5/ioc/internal/util/AbstractResource.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f0436696/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
index 862f303..7af7c48 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
@@ -286,7 +286,7 @@ public abstract class AbstractResource extends LockSupport implements Resource
             // TAP5-2448: make sure that the URL does not reference a directory
             String urlAsString = url.toString();
 
-            int indexOfExclamationMark = url.toString().indexOf('!');
+            int indexOfExclamationMark = urlAsString.indexOf('!');
 
             String resourceInJar = urlAsString.substring(indexOfExclamationMark + 2);
 


[2/2] tapestry-5 git commit: TAP5-2448, TAP5-2517: check that the directory is inside a JAR file

Posted by jk...@apache.org.
TAP5-2448, TAP5-2517: check that the directory is inside a JAR file


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/c61335a1
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/c61335a1
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/c61335a1

Branch: refs/heads/master
Commit: c61335a151b193730555a62c20e397a675305a6d
Parents: f043669
Author: Jochen Kemnade <jo...@eddyson.de>
Authored: Thu Nov 12 10:34:43 2015 +0100
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Thu Nov 12 10:34:43 2015 +0100

----------------------------------------------------------------------
 .../ioc/internal/util/AbstractResource.java     |  4 +++-
 .../ioc/specs/ClasspathResourceSpec.groovy      | 22 ++++++++++++++++++++
 .../META-INF/maven/org.slf4j/slf4j-api/pom.xml  |  2 ++
 3 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c61335a1/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
index 7af7c48..2ead75e 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
@@ -290,7 +290,9 @@ public abstract class AbstractResource extends LockSupport implements Resource
 
             String resourceInJar = urlAsString.substring(indexOfExclamationMark + 2);
 
-            boolean isDirectory = Thread.currentThread().getContextClassLoader().getResource(resourceInJar + "/") != null;
+            URL directoryResource = Thread.currentThread().getContextClassLoader().getResource(resourceInJar + "/");
+
+            boolean isDirectory = directoryResource != null && "jar".equals(directoryResource.getProtocol());
 
             if (isDirectory)
             {

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c61335a1/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy b/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy
index a7829bc..6f446cb 100644
--- a/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy
@@ -1,7 +1,10 @@
 package ioc.specs
 
+import java.security.AccessController;
+
 import org.apache.commons.lang3.SystemUtils
 import org.apache.tapestry5.ioc.internal.util.ClasspathResource
+import org.slf4j.Logger;
 
 import spock.lang.Issue;
 import spock.lang.Specification
@@ -279,4 +282,23 @@ class ClasspathResourceSpec extends Specification {
       notThrown(IOException)
     }
 
+    @Issue('TAP5-2517')
+    def "Can open a stream for a file resource within a JAR file that has a duplicate on the classpath"() {
+      setup:
+      def currentCl = Thread.currentThread().contextClassLoader 
+      
+      def loadedURLs = currentCl.ucp.path
+      def slf4jApiFirst = loadedURLs.sort{!it.toString().contains('slf4j-api')}
+      
+      ClassLoader cl = new URLClassLoader(slf4jApiFirst as URL[], null, AccessController.getContext())
+     
+      ClasspathResource r = new ClasspathResource(cl, '/META-INF/maven/org.slf4j/slf4j-api/pom.xml')
+
+      when:
+      r.openStream()
+      then:
+      notThrown(IOException)
+     
+    }
+    
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c61335a1/tapestry-ioc/src/test/resources/META-INF/maven/org.slf4j/slf4j-api/pom.xml
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/resources/META-INF/maven/org.slf4j/slf4j-api/pom.xml b/tapestry-ioc/src/test/resources/META-INF/maven/org.slf4j/slf4j-api/pom.xml
new file mode 100644
index 0000000..6199647
--- /dev/null
+++ b/tapestry-ioc/src/test/resources/META-INF/maven/org.slf4j/slf4j-api/pom.xml
@@ -0,0 +1,2 @@
+This is a test file for TAP5-2517.
+See ioc.specs.ClasspathResourceSpec.Can open a stream for a file resource within a JAR file that has a duplicate on the classpath()
\ No newline at end of file


[2/2] tapestry-5 git commit: TAP5-2448, TAP5-2517: check that the directory is inside a JAR file

Posted by jk...@apache.org.
TAP5-2448, TAP5-2517: check that the directory is inside a JAR file


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/c61335a1
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/c61335a1
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/c61335a1

Branch: refs/heads/master
Commit: c61335a151b193730555a62c20e397a675305a6d
Parents: f043669
Author: Jochen Kemnade <jo...@eddyson.de>
Authored: Thu Nov 12 10:34:43 2015 +0100
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Thu Nov 12 10:34:43 2015 +0100

----------------------------------------------------------------------
 .../ioc/internal/util/AbstractResource.java     |  4 +++-
 .../ioc/specs/ClasspathResourceSpec.groovy      | 22 ++++++++++++++++++++
 .../META-INF/maven/org.slf4j/slf4j-api/pom.xml  |  2 ++
 3 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c61335a1/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
index 7af7c48..2ead75e 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
@@ -290,7 +290,9 @@ public abstract class AbstractResource extends LockSupport implements Resource
 
             String resourceInJar = urlAsString.substring(indexOfExclamationMark + 2);
 
-            boolean isDirectory = Thread.currentThread().getContextClassLoader().getResource(resourceInJar + "/") != null;
+            URL directoryResource = Thread.currentThread().getContextClassLoader().getResource(resourceInJar + "/");
+
+            boolean isDirectory = directoryResource != null && "jar".equals(directoryResource.getProtocol());
 
             if (isDirectory)
             {

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c61335a1/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy b/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy
index a7829bc..6f446cb 100644
--- a/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy
@@ -1,7 +1,10 @@
 package ioc.specs
 
+import java.security.AccessController;
+
 import org.apache.commons.lang3.SystemUtils
 import org.apache.tapestry5.ioc.internal.util.ClasspathResource
+import org.slf4j.Logger;
 
 import spock.lang.Issue;
 import spock.lang.Specification
@@ -279,4 +282,23 @@ class ClasspathResourceSpec extends Specification {
       notThrown(IOException)
     }
 
+    @Issue('TAP5-2517')
+    def "Can open a stream for a file resource within a JAR file that has a duplicate on the classpath"() {
+      setup:
+      def currentCl = Thread.currentThread().contextClassLoader 
+      
+      def loadedURLs = currentCl.ucp.path
+      def slf4jApiFirst = loadedURLs.sort{!it.toString().contains('slf4j-api')}
+      
+      ClassLoader cl = new URLClassLoader(slf4jApiFirst as URL[], null, AccessController.getContext())
+     
+      ClasspathResource r = new ClasspathResource(cl, '/META-INF/maven/org.slf4j/slf4j-api/pom.xml')
+
+      when:
+      r.openStream()
+      then:
+      notThrown(IOException)
+     
+    }
+    
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c61335a1/tapestry-ioc/src/test/resources/META-INF/maven/org.slf4j/slf4j-api/pom.xml
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/resources/META-INF/maven/org.slf4j/slf4j-api/pom.xml b/tapestry-ioc/src/test/resources/META-INF/maven/org.slf4j/slf4j-api/pom.xml
new file mode 100644
index 0000000..6199647
--- /dev/null
+++ b/tapestry-ioc/src/test/resources/META-INF/maven/org.slf4j/slf4j-api/pom.xml
@@ -0,0 +1,2 @@
+This is a test file for TAP5-2517.
+See ioc.specs.ClasspathResourceSpec.Can open a stream for a file resource within a JAR file that has a duplicate on the classpath()
\ No newline at end of file