Index: src/java/org/apache/ivy/plugins/lock/FileBasedLockStrategy.java
===================================================================
--- src/java/org/apache/ivy/plugins/lock/FileBasedLockStrategy.java	(revision 1493256)
+++ src/java/org/apache/ivy/plugins/lock/FileBasedLockStrategy.java	(working copy)
@@ -20,7 +20,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.RandomAccessFile;
-import java.nio.channels.FileChannel;
 import java.nio.channels.FileLock;
 import java.util.HashMap;
 import java.util.Map;
@@ -46,11 +45,11 @@
     private Map/*<File, Integer>*/ currentLockCounters = new HashMap();
     
     protected FileBasedLockStrategy() {
-        this(new CreateFileLocker(false), false);
+        this(new NIOFileLocker(false), false);
     }
 
     protected FileBasedLockStrategy(boolean debugLocking) {
-        this(new CreateFileLocker(debugLocking), debugLocking);
+        this(new NIOFileLocker(debugLocking), debugLocking);
     }
 
     protected FileBasedLockStrategy(FileLocker locker, boolean debugLocking) {
@@ -183,26 +182,30 @@
             this.debugLocking = debugLocking;
         }
 
+        static class LockData {
+            LockData(RandomAccessFile raf, FileLock l) {
+                this.raf = raf;
+                this.l = l;
+            }
+            RandomAccessFile raf;
+            FileLock l;
+        }
+
         public boolean tryLock(File file) {
             try {
                 if (file.getParentFile().exists() || file.getParentFile().mkdirs()) {
                     RandomAccessFile raf =
                         new RandomAccessFile(file, "rw");            
-                    FileChannel channel = raf.getChannel();
-                    try {
-                        FileLock l = channel.tryLock();
-                        if (l != null) {
-                            synchronized (this) {
-                                locks.put(file, l);
-                            }
-                            return true;
-                        } else {
-                            if (debugLocking) {
-                                debugLocking("failed to acquire lock on " + file);
-                            }
+                    FileLock l = raf.getChannel().tryLock();
+                    if (l != null) {
+                        synchronized (this) {
+                            locks.put(file, new LockData(raf, l));
                         }
-                    } finally {
-                        raf.close();
+                        return true;
+                    } else {
+                        if (debugLocking) {
+                            debugLocking("failed to acquire lock on " + file);
+                        }
                     }
                 }
             } catch (IOException e) {
@@ -215,12 +218,15 @@
 
         public void unlock(File file) {
             synchronized (this) {
-                FileLock l = (FileLock) locks.get(file);
-                if (l == null) {
+                LockData data = (LockData) locks.get(file);
+                if (data == null) {
                     throw new IllegalArgumentException("file not previously locked: " + file);
                 }
+
                 try {
-                    l.release();
+                    locks.remove(file); /* do this first to remove reference to objects */
+                    data.l.release(); /* not actually a necessary step on UNIX; closing the file releases the lock */
+                    data.raf.close();
                 } catch (IOException e) {
                     Message.error(
                         "problem while releasing lock on " + file + ": " + e.getMessage());
