harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r417384 - in /incubator/harmony/enhanced/classlib/trunk/modules/nio/src: main/java/java/nio/channels/FileLock.java test/java/org/apache/harmony/tests/java/nio/channels/FileLockTest.java
Date Tue, 27 Jun 2006 09:19:55 GMT
Author: gharley
Date: Tue Jun 27 02:19:54 2006
New Revision: 417384

URL: http://svn.apache.org/viewvc?rev=417384&view=rev
Log:
HARMONY 671 : FileLock.overlaps() should return true when the lock range is a subset of the
given one

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/channels/FileLock.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/FileLockTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/channels/FileLock.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/channels/FileLock.java?rev=417384&r1=417383&r2=417384&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/channels/FileLock.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/channels/FileLock.java
Tue Jun 27 02:19:54 2006
@@ -154,11 +154,13 @@
 	 * @return true if there is an overlap, and false otherwise.
 	 */
 	public final boolean overlaps(long start, long length) {
-		final long myEnd = position + size - 1;
-		final long otherEnd = start + length - 1;
-		return ((start >= position) && (start <= myEnd))
-				|| ((otherEnd >= position) && (otherEnd <= myEnd));
-	}
+        final long end = position + size - 1;
+        final long newEnd = start + length - 1;
+        if (end < start || position > newEnd) {
+            return false;
+        }
+        return true;
+    }
 
 	/**
 	 * Answers whether the receiver is a valid file lock or not. The lock is

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/FileLockTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/FileLockTest.java?rev=417384&r1=417383&r2=417384&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/FileLockTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/FileLockTest.java
Tue Jun 27 02:19:54 2006
@@ -135,6 +135,9 @@
 		assertTrue(mockLock.overlaps(100, 110));
 		assertTrue(mockLock.overlaps(99, 110));
 		assertFalse(mockLock.overlaps(-1, 10));
+        //Harmony-671 regression test
+        assertTrue(mockLock.overlaps(1, 120));
+        assertTrue(mockLock.overlaps(20, 50));
 	}
 
 	/**



Mime
View raw message