Bug 21372 - FileChannel.tryLock() return value incorrect
Summary: FileChannel.tryLock() return value incorrect
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/java-patches/20...
Keywords: patch
Depends on:
Blocks:
 
Reported: 2005-05-03 21:23 UTC by Andrew Overholt
Modified: 2005-05-03 22:48 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-05-03 21:56:01


Attachments
test case part 1 (271 bytes, text/x-java)
2005-05-03 21:24 UTC, Andrew Overholt
Details
test case part 1 (277 bytes, text/x-java)
2005-05-03 21:28 UTC, Andrew Overholt
Details
second part to the test case (298 bytes, text/x-java)
2005-05-03 21:29 UTC, Andrew Overholt
Details
patch (668 bytes, patch)
2005-05-03 21:44 UTC, Andrew Overholt
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Overholt 2005-05-03 21:23:47 UTC
According to the spec, FileChannel.tryLock() should return null in the event
that it cannot acquire a lock.  libgcj's implementation does not currently do
this and returns a FileLock object even though the lock has not been acquired. 
See attached test case.
Comment 1 Andrew Overholt 2005-05-03 21:24:56 UTC
Created attachment 8810 [details]
test case part 1

Run this part first.
Comment 2 Andrew Overholt 2005-05-03 21:28:39 UTC
Created attachment 8811 [details]
test case part 1

Run this file and leave it running while you try to run the second attachment
(forthcoming).
Comment 3 Andrew Overholt 2005-05-03 21:29:22 UTC
Created attachment 8812 [details]
second part to the test case

Run this while TestLocking2 is running.
Comment 4 Andrew Overholt 2005-05-03 21:44:02 UTC
Created attachment 8813 [details]
patch
Comment 5 Tom Tromey 2005-05-03 21:54:29 UTC
This patch looks good to me.
Could you write a ChangeLog entry for it?
Comment 6 Andrew Pinski 2005-05-03 21:56:00 UTC
(In reply to comment #5)
> This patch looks good to me.
> Could you write a ChangeLog entry for it?
He did in <http://gcc.gnu.org/ml/java-patches/2005-q2/msg00371.html>

Confirmed,
Comment 7 Bryce McKinlay 2005-05-03 21:57:14 UTC
There is already a ChangeLog entry with the patch
Comment 8 GCC Commits 2005-05-03 22:38:48 UTC
Subject: Bug 21372

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2005-05-03 22:38:17

Modified files:
	libjava        : ChangeLog 
	libjava/java/nio/channels: FileLock.java 
	libjava/gnu/java/nio/channels: FileChannelImpl.java 

Log message:
	2005-05-03  Andrew Overholt  <overholt@redhat.com>
	
	PR libgcj/21372:
	* gnu/java/nio/channels/FileChannelImpl.java: Return null if lock
	could not be acquired.
	* java/nio/channels/FileLock.java (toString): Re-implement to be
	in line with other implementations.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3584&r2=1.3585
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/nio/channels/FileLock.java.diff?cvsroot=gcc&r1=1.4&r2=1.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/gnu/java/nio/channels/FileChannelImpl.java.diff?cvsroot=gcc&r1=1.10&r2=1.11

Comment 9 GCC Commits 2005-05-03 22:47:29 UTC
Subject: Bug 21372

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	tromey@gcc.gnu.org	2005-05-03 22:47:13

Modified files:
	libjava        : ChangeLog 
	libjava/java/nio/channels: FileLock.java 
	libjava/gnu/java/nio/channels: FileChannelImpl.java 

Log message:
	2005-05-03  Andrew Overholt  <overholt@redhat.com>
	
	PR libgcj/21372:
	* gnu/java/nio/channels/FileChannelImpl.java: Return null if lock
	could not be acquired.
	* java/nio/channels/FileLock.java (toString): Re-implement to be
	in line with other implementations.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.3391.2.56&r2=1.3391.2.57
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/nio/channels/FileLock.java.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4&r2=1.4.40.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/gnu/java/nio/channels/FileChannelImpl.java.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.7.4.2&r2=1.7.4.3

Comment 10 Tom Tromey 2005-05-03 22:48:48 UTC
I checked in the fix to the trunk, the 4.0 branch, and Classpath.
Thanks for the clear test case and patch.