This content has been marked as final.
Show 7 replies
-
1. Re: VFS locking
alesj Jun 20, 2008 11:58 AM (in response to starksm64)This should be removed asap.
Marko? -
2. Re: VFS locking
mstruk Jun 20, 2008 1:23 PM (in response to starksm64)I'll look into it over the weekend.
- marko -
3. Re: VFS locking
alesj Jun 27, 2008 6:00 AM (in response to starksm64)I found this comment in some decent non-JBoss code:
/** * This implementation opens an InputStream for the given URL. * It sets the "UseCaches" flag to <code>false</code>, * mainly to avoid jar file locking on Windows.
See last line. ;-) -
4. Re: VFS locking
dimitris Jun 27, 2008 6:42 AM (in response to starksm64)so there is a magic flag, after all?
-
5. Re: VFS locking
anil.saldhana Jun 27, 2008 8:40 AM (in response to starksm64)The best flag is get off Windows. Unfortunately, not a solution for many. :)
-
6. Re: VFS locking
mstruk Jun 30, 2008 3:21 PM (in response to starksm64)so there is a magic flag, after all?
There is a flag, but it's not magic :)
I've spent a lot of time on this lately.
A general rule that works for file: urls (but not for jar:file: urls) is the following:URLConnection conn = fileUrl.openConnection(); InputStream in = conn.getInputStream(); long lastModified; try { lastModified = conn.getLastModified(); System.out.println("lastModified, "+lastModified); } finally { in.close(); }
It's getting and closing the InputStream that does the trick.
For jar:file: urls I could only achieve file lock release by triggering finalizers - which means it's pretty useless for anything but tests maybe:URLConnection conn = jarFileUrl.openConnection(); conn.setUseCaches(false); long lastModified = conn.getLastModified(); conn = null; jarFileUrl = null; System.gc(); Thread.sleep(500); System.gc();
In this case I'd say the problem is more with JDK implementation than Windows :)
- marko -
7. Re: VFS locking
starksm64 Jun 30, 2008 3:54 PM (in response to starksm64)"mstruk" wrote:
In this case I'd say the problem is more with JDK implementation than Windows :)
Which is why we want to move away from the jdk url handler reliance. Its a poor api and has unreliable behavior across platforms. All of the jar/zip file behaviors ultimately rely on native code as well.