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/04/10 17:55:24 UTC
tapestry-5 git commit: TAP5-2448: URLClassLoader did not implement
Closable before Java 7, use the current thread's context ClassLoader
Repository: tapestry-5
Updated Branches:
refs/heads/master a600b6b24 -> 55a8fad26
TAP5-2448: URLClassLoader did not implement Closable before Java 7, use the current thread's context ClassLoader
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/55a8fad2
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/55a8fad2
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/55a8fad2
Branch: refs/heads/master
Commit: 55a8fad26f7438e19dd16d30ff22a3f8d51f87b0
Parents: a600b6b
Author: Jochen Kemnade <jk...@apache.org>
Authored: Fri Apr 10 17:53:23 2015 +0200
Committer: Jochen Kemnade <jk...@apache.org>
Committed: Fri Apr 10 17:53:23 2015 +0200
----------------------------------------------------------------------
.../ioc/internal/util/AbstractResource.java | 30 ++++++--------------
1 file changed, 8 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/55a8fad2/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 a05b2bc..e8076b2 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
@@ -12,7 +12,6 @@
package org.apache.tapestry5.ioc.internal.util;
-import org.apache.commons.io.IOUtils;
import org.apache.tapestry5.ioc.Resource;
import org.apache.tapestry5.ioc.util.LocalizedNameGenerator;
@@ -22,7 +21,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
-import java.net.URLClassLoader;
import java.util.List;
import java.util.Locale;
@@ -284,33 +282,21 @@ public abstract class AbstractResource extends LockSupport implements Resource
}
if ("jar".equals(url.getProtocol())){
- URLClassLoader classLoaderWithJar = null;
- try
- {
-
- // TAP5-2448: make sure that the URL does not reference a directory
- String urlAsString = url.toString();
-
- int indexOfExclamationMark = url.toString().indexOf('!');
+ // TAP5-2448: make sure that the URL does not reference a directory
+ String urlAsString = url.toString();
- String jarFile = urlAsString.substring(4, indexOfExclamationMark);
- String resourceInJar = urlAsString.substring(indexOfExclamationMark + 2);
+ int indexOfExclamationMark = url.toString().indexOf('!');
- classLoaderWithJar = new URLClassLoader(new URL[]{ new URL(jarFile) });
+ String resourceInJar = urlAsString.substring(indexOfExclamationMark + 2);
- boolean isDirectory = classLoaderWithJar.getResource(resourceInJar + "/") != null;
+ boolean isDirectory = Thread.currentThread().getContextClassLoader().getResource(resourceInJar + "/") != null;
- classLoaderWithJar.close();
-
- if (isDirectory)
- {
- throw new IOException("Cannot open a steam for a resource that references a directory inside a JAR file (" + url + ").");
- }
- } finally
+ if (isDirectory)
{
- IOUtils.closeQuietly(classLoaderWithJar);
+ throw new IOException("Cannot open a steam for a resource that references a directory inside a JAR file (" + url + ").");
}
+
}
return new BufferedInputStream(url.openStream());