Community
Participate
Working Groups
On a 1.5 VM, the file level locking doesn't appear to 'lock' a location between threads in the same process. That is, if one thread calls lock(), and another thread calls isLocked(), on a 1.5 VM, the call to isLocked() will return *false*, whereas on a 1.6 VM the call to isLocked() will return *true*. This code snippet demonstrates the problem: public Object start(IApplicationContext context) throws Exception { Thread t = new Thread(new Runnable() { public void run() { try { lockLocation = getLockLocation(new URI("file:///home/irbull/tmp/locktest"), 1); lockLocation.lock(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } } }); t.start(); t.join(); System.out.println(getLockLocation(new URI("file:///home/irbull/tmp/locktest"),1).isLocked()); } private static Location getLockLocation(URI baseLocation, int locationNumber) throws IllegalStateException, IOException { Location anyLoc = (Location) Activator.getService(Location.class.getName()); URI locationURI = URIUtil.append(baseLocation, "" + locationNumber); Location location = anyLoc.createLocation(null, URIUtil.toURL(locationURI), false); //$NON-NLS-1$ location.set(URIUtil.toURL(locationURI),false); return location; } I didn't see either behaviour specified in the Location class, but maybe I missed it. This doesn't represent a regression as this never worked before. However, we should fix this for 3.7.
Within the same VM you should really use the same Location object. That is why we register the locations as a service, so that all clients within the same framework are using the same instance. The Location object contains state to keep track if the location has been locked within the same process.
Created attachment 192112 [details] Patch v1 This patch uses a static map to manage the Lock locations. We need to consider what to do with these locations on bundle.stop().
Created attachment 192113 [details] mylyn/context/zip
Created attachment 192115 [details] Patch v2 I've moved the cache to the activator so we can clean it up on stop() / start().
Created attachment 192116 [details] mylyn/context/zip
I've added some comments and released patch v2 to head. I've also enabled some more test cases that demonstrate this behaviour.