tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominik Drzewiecki" <drz...@post.pl>
Subject Re: JDTCompiler and locked jar files *again*
Date Fri, 17 Dec 2004 13:00:38 GMT
Remy Maucherat <remm@apache.org> wrote:
> 
> It's a hack though. JasperLoader shouldn't have the JARs in its 
> repositories, so it is supposed to delegate.

It *does* delegate to its parent classloader (which is WebappClassLoader)
The only difference is that my solution sets useCaches to false on obtained 
URLConnection before opening an InputStream.
There are no repositories related with JasperLoader.
Look:

in o.a.j.c.JDTCompiler there is such an invocation in findType(String)

is = classLoader.getResourceAsStream(resourceName);

classLoader is an instance of JasperLoader, which does not override 
j.n.URLClassLoader.getResourceAsStream(String)
Since there is also no getResourceAsStream in its superclass 
j.n.URLClasLoader, ClassLoader's implementation getResourceAsStream(String) 
is used
It (java.lang.ClassLoader) is implemented like this:
    
public InputStream getResourceAsStream(String name) {
	URL url = getResource(name);
	try {
	    return url != null ? url.openStream() : null;
	} catch (IOException e) {
	    return null;
	}
    }

Notice that openStream() is a short for getConnection().getInputStream().

As you can clearly see after applying my "hack" after an invocation of

is = classLoader.getResourceAsStream(resourceName);

"is" is assigned an InputStream opened on an *uncached* JarURLConnection.

Te question arises - is there any benefit of having cached 
JarURLConnection??
I haven't checked that in the sources of jdk as java.net.JarURLConnection 
is abstract and implemented in sun.net.www.protocol.jar.JarURLConnection.

> 
>> PS. I hope that I don't get cursed again.
> 
> It's easy: don't be annoying, and avoid whining.

I try hard not to be annoying.
And I'am not whining - I try to be helpfull.

> 
> For example, what's up with that bug ?
> http://issues.apache.org/bugzilla/show_bug.cgi?id=32746
> Is it relevant or not ?

It is. It is an outcome of my investigation. Fixing it (closing the stream),
 however, does no good.
But I'm pretty sure it is a good habit to cleanup.

cheers,
/dd


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message