From Thomas.Salter at unisys.com Tue Aug 9 12:43:46 2011 From: Thomas.Salter at unisys.com (Salter, Thomas A) Date: Tue, 9 Aug 2011 14:43:46 -0500 Subject: WindowsFileSystemProvider checkAccess Message-ID: <63D5DCACD1E9E34C89C8203C64F521C3FE4FADC24C@USEA-EXCH7.na.uis.unisys.com> I've encountered a problem with WindowsFileSystemProvider checkAccess function. When I'm running as an administrator, everything is fine, but when I run as an ordinary user (member of the default Users group), the GetEffectiveRightsFromAcl function fails with an Access Denied (5) error result. I've tried giving the individual user as well as the Users group "full control", but the only thing that seems to work is running under an administrator account. I'm proven that the user does have access to the file by reading from the file from the same program after isReadable() returns false. My test program is included below. I'm running on Windows 7 with the FCS version of Java 7 downloaded from the public Java technology site: http://www.oracle.com/technetwork/java/index.html Along the way, I noticed that WindowsNativeDispatcher.c does not test correctly for an error code. The actual error is returned as the result, not with GetLastError. My suggested change follows: #if OLD CODE if (GetEffectiveRightsFromAcl(pAcl, pTrustee, &access) != ERROR_SUCCESS) { throwWindowsException(env, GetLastError()); } #else //NEW CODE DWORD result = GetEffectiveRightsFromAcl(pAcl, pTrustee, &access); if( result != ERROR_SUCCESS) { throwWindowsException(env, result ); } #endif import java.io.*; import java.nio.charset.*; import java.nio.file.*; public class WinNIO { public static void main(String[] args) throws IOException { WinNIO nio = new WinNIO(); nio.testReadable( "C:\\Windows\\System32\\drivers\\etc\\hosts" ); nio.testReadable( "C:\\java\\jdk7_fcs\\jre\\readme.txt" ); } void testReadable(String file) throws IOException { Path path = Paths.get( file ); boolean isReadable = Files.isReadable( path ); System.out.println(path + ": isReadable:" + isReadable ); BufferedReader br = Files.newBufferedReader( path, Charset.defaultCharset() ); LineNumberReader lr = new LineNumberReader(br); String line = lr.readLine(); System.out.println(line); } } Tom Salter | Software Engineer | Java & Middleware Development Unisys | 476 Swedesford Road | Malvern, PA 19355 | 610-648-2568 | N385-2568 [cid:image001.gif at 01CC56A5.AEDEEEA0] THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20110809/7fac487b/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: image/gif Size: 2511 bytes Desc: image001.gif Url : http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20110809/7fac487b/attachment-0001.gif From Alan.Bateman at oracle.com Tue Aug 9 13:37:42 2011 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 09 Aug 2011 21:37:42 +0100 Subject: WindowsFileSystemProvider checkAccess In-Reply-To: <63D5DCACD1E9E34C89C8203C64F521C3FE4FADC24C@USEA-EXCH7.na.uis.unisys.com> References: <63D5DCACD1E9E34C89C8203C64F521C3FE4FADC24C@USEA-EXCH7.na.uis.unisys.com> Message-ID: <4E419A96.4070705@oracle.com> Salter, Thomas A wrote: > > I've encountered a problem with WindowsFileSystemProvider checkAccess > function. When I'm running as an administrator, everything is fine, > but when I run as an ordinary user (member of the default Users > group), the GetEffectiveRightsFromAcl function fails with an Access > Denied (5) error result. I've tried giving the individual user as > well as the Users group "full control", but the only thing that seems > to work is running under an administrator account. > > > > I'm proven that the user does have access to the file by reading from > the file from the same program after isReadable() returns false. My > test program is included below. > > > > I'm running on Windows 7 with the FCS version of Java 7 downloaded > from the public Java technology site: > http://www.oracle.com/technetwork/java/index.html > > > > Along the way, I noticed that WindowsNativeDispatcher.c does not test > correctly for an error code. The actual error is returned as the > result, not with GetLastError. My suggested change follows: > > > > #if OLD CODE > > if (GetEffectiveRightsFromAcl(pAcl, pTrustee, &access) != > ERROR_SUCCESS) { > > throwWindowsException(env, GetLastError()); > > } > > #else //NEW CODE > > DWORD result = GetEffectiveRightsFromAcl(pAcl, pTrustee, &access); > > if( result != ERROR_SUCCESS) { > > throwWindowsException(env, result ); > > } > > #endif > It might be a few days before I can look into this in detail. One thing that would be useful is if you could say whether you are in a domain and whether you are logged in with a local account (when using the user account). If I can't duplicate this then I might ask you to dump the ACL so that we can see whether it accessible by the domain group (cacls.exe can be used to print it out, as can the AclEdit sample in the JDK sample directory). On the above code then you are right as we should be use the return value as the error code. Looking at this API then I also wonder if we should be using the Unicode version (need to check that too). -Alan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20110809/53d32586/attachment.html From Thomas.Salter at unisys.com Tue Aug 9 13:51:53 2011 From: Thomas.Salter at unisys.com (Salter, Thomas A) Date: Tue, 9 Aug 2011 15:51:53 -0500 Subject: WindowsFileSystemProvider checkAccess In-Reply-To: <4E419A96.4070705@oracle.com> References: <63D5DCACD1E9E34C89C8203C64F521C3FE4FADC24C@USEA-EXCH7.na.uis.unisys.com> <4E419A96.4070705@oracle.com> Message-ID: <63D5DCACD1E9E34C89C8203C64F521C3FE4FADC399@USEA-EXCH7.na.uis.unisys.com> From: Alan Bateman [mailto:Alan.Bateman at oracle.com] Sent: Tuesday, August 09, 2011 4:38 PM To: Salter, Thomas A Cc: nio-dev at openjdk.java.net Subject: Re: WindowsFileSystemProvider checkAccess Salter, Thomas A wrote: I've encountered a problem with WindowsFileSystemProvider checkAccess function. When I'm running as an administrator, everything is fine, but when I run as an ordinary user (member of the default Users group), the GetEffectiveRightsFromAcl function fails with an Access Denied (5) error result. I've tried giving the individual user as well as the Users group "full control", but the only thing that seems to work is running under an administrator account. I'm proven that the user does have access to the file by reading from the file from the same program after isReadable() returns false. My test program is included below. I'm running on Windows 7 with the FCS version of Java 7 downloaded from the public Java technology site: http://www.oracle.com/technetwork/java/index.html Along the way, I noticed that WindowsNativeDispatcher.c does not test correctly for an error code. The actual error is returned as the result, not with GetLastError. My suggested change follows: #if OLD CODE if (GetEffectiveRightsFromAcl(pAcl, pTrustee, &access) != ERROR_SUCCESS) { throwWindowsException(env, GetLastError()); } #else //NEW CODE DWORD result = GetEffectiveRightsFromAcl(pAcl, pTrustee, &access); if( result != ERROR_SUCCESS) { throwWindowsException(env, result ); } #endif It might be a few days before I can look into this in detail. One thing that would be useful is if you could say whether you are in a domain and whether you are logged in with a local account (when using the user account). If I can't duplicate this then I might ask you to dump the ACL so that we can see whether it accessible by the domain group (cacls.exe can be used to print it out, as can the AclEdit sample in the JDK sample directory). On the above code then you are right as we should be use the return value as the error code. Looking at this API then I also wonder if we should be using the Unicode version (need to check that too). -Alan [Salter, Thomas A] I am normally logged in as a domain user who is a member of the BUILTIN\Administrators account. The ordinary user is a local user that's a member of BUILTIN\Users. I ran as the local user while signed in as an administrator by using RunAs from the command prompt. I thought maybe I didn't have permission to read the ACLs but I was able to run cacls while signed in as the ordinary user. The ACLs don't seem very interesting: C:\>cacls C:\Windows\System32\drivers\etc\hosts C:\Windows\System32\drivers\etc\hosts BUILTIN\Administrators:(ID)F NT AUTHORITY\SYSTEM:(ID)F BUILTIN\Users:(ID)R C:\>cacls C:\Java\jdk7_fcs\jre\readme.txt C:\Java\jdk7_fcs\jre\README.txt BUILTIN\Administrators:(ID)F NT AUTHORITY\SYSTEM:(ID)F BUILTIN\Users:(ID)R NT AUTHORITY\Authenticated Users:(ID)C -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20110809/8782f06e/attachment-0001.html From Alan.Bateman at oracle.com Tue Aug 9 14:07:24 2011 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 09 Aug 2011 22:07:24 +0100 Subject: WindowsFileSystemProvider checkAccess In-Reply-To: <63D5DCACD1E9E34C89C8203C64F521C3FE4FADC399@USEA-EXCH7.na.uis.unisys.com> References: <63D5DCACD1E9E34C89C8203C64F521C3FE4FADC24C@USEA-EXCH7.na.uis.unisys.com> <4E419A96.4070705@oracle.com> <63D5DCACD1E9E34C89C8203C64F521C3FE4FADC399@USEA-EXCH7.na.uis.unisys.com> Message-ID: <4E41A18C.40404@oracle.com> Salter, Thomas A wrote: > *:* > > > */[Salter, Thomas A] /*I am normally logged in as a domain user who is > a member of the BUILTIN\Administrators account. The ordinary user is > a local user that's a member of BUILTIN\Users. I ran as the local > user while signed in as an administrator by using RunAs from the > command prompt. I thought maybe I didn't have permission to read the > ACLs but I was able to run cacls while signed in as the ordinary user. > > > > The ACLs don't seem very interesting: > > C:\>cacls C:\Windows\System32\drivers\etc\hosts > > C:\Windows\System32\drivers\etc\hosts BUILTIN\Administrators:(ID)F > > NT AUTHORITY\SYSTEM:(ID)F > > BUILTIN\Users:(ID)R > > > > > > C:\>cacls C:\Java\jdk7_fcs\jre\readme.txt > > C:\Java\jdk7_fcs\jre\README.txt BUILTIN\Administrators:(ID)F > > NT AUTHORITY\SYSTEM:(ID)F > > BUILTIN\Users:(ID)R > > NT AUTHORITY\Authenticated Users:(ID)C > > > > / / > > I need to double check but I think that GetEffectiveRightsFromAcl needs to enumerate these groups in the active directory and this is failing because the account is local. That would explain why you can read the DACL but not determine the effective access. -Alan. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20110809/09e007db/attachment.html From sean.coffey at oracle.com Wed Aug 10 01:34:56 2011 From: sean.coffey at oracle.com (=?ISO-8859-1?Q?Se=E1n_Coffey?=) Date: Wed, 10 Aug 2011 09:34:56 +0100 Subject: Code review request : 7047325 Message-ID: <4E4242B0.2010902@oracle.com> CR 7047325 is an internal RFE : Internal API to improve management of direct buffers This RFE was introduced in a 6 update release and with jdk 7 & jdk 8 in the open, I'm porting this change forward from the proprietary jdk6 updates. The change adds an internal API to improve the management of direct buffers. This request is for jdk 8 : http://cr.openjdk.java.net/~coffeys/7047325.jdk8/ regards, Sean. From Alan.Bateman at oracle.com Wed Aug 10 03:22:42 2011 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 10 Aug 2011 11:22:42 +0100 Subject: Code review request : 7047325 In-Reply-To: <4E4242B0.2010902@oracle.com> References: <4E4242B0.2010902@oracle.com> Message-ID: <4E425BF2.4070202@oracle.com> Se?n Coffey wrote: > CR 7047325 is an internal RFE : Internal API to improve management of > direct buffers > > This RFE was introduced in a 6 update release and with jdk 7 & jdk 8 > in the open, I'm porting this change forward from the proprietary jdk6 > updates. The change adds an internal API to improve the management of > direct buffers. > > This request is for jdk 8 : > http://cr.openjdk.java.net/~coffeys/7047325.jdk8/ > > regards, > Sean. Thanks for doing this, the changes look fine to me. -Alan. From mike.duigou at oracle.com Wed Aug 10 08:40:51 2011 From: mike.duigou at oracle.com (Mike Duigou) Date: Wed, 10 Aug 2011 08:40:51 -0700 Subject: Code review request : 7047325 In-Reply-To: <4E4242B0.2010902@oracle.com> References: <4E4242B0.2010902@oracle.com> Message-ID: <5039BBA9-CF17-48CA-8919-27B01D380E22@oracle.com> src/share/classes/sun/misc/JavaNioAccess.java: - the javadoc refers to {@code capacity} whereas the actual param is named "cap". Any reason to us a prose description rather than @param tags? src/share/classes/java/nio/Direct-X-Buffer.java.template: - The comment upon "att" is not a javadoc comment. (this also seems to apply to many other comments in this file). unit test updates or additions? Mike On Aug 10 2011, at 01:34 , Se?n Coffey wrote: > CR 7047325 is an internal RFE : Internal API to improve management of direct buffers > > This RFE was introduced in a 6 update release and with jdk 7 & jdk 8 in the open, I'm porting this change forward from the proprietary jdk6 updates. The change adds an internal API to improve the management of direct buffers. > > This request is for jdk 8 : http://cr.openjdk.java.net/~coffeys/7047325.jdk8/ > > regards, > Sean. From sean.coffey at oracle.com Wed Aug 10 09:23:29 2011 From: sean.coffey at oracle.com (=?ISO-8859-1?Q?Se=E1n_Coffey?=) Date: Wed, 10 Aug 2011 17:23:29 +0100 Subject: Code review request : 7047325 In-Reply-To: <5039BBA9-CF17-48CA-8919-27B01D380E22@oracle.com> References: <4E4242B0.2010902@oracle.com> <5039BBA9-CF17-48CA-8919-27B01D380E22@oracle.com> Message-ID: <4E42B081.7030509@oracle.com> Thanks for catching that Mike. The API is internal in any case and javadoc won't be public. webrev updated. I've updated the capacity-> cap comment. (and an erroneous "is an" ) Testcase to accompany the internal API code. regards, Sean. On 08/10/2011 04:40 PM, Mike Duigou wrote: > src/share/classes/sun/misc/JavaNioAccess.java: > - the javadoc refers to {@code capacity} whereas the actual param is named "cap". Any reason to us a prose description rather than @param tags? > > src/share/classes/java/nio/Direct-X-Buffer.java.template: > - The comment upon "att" is not a javadoc comment. (this also seems to apply to many other comments in this file). > > unit test updates or additions? > > Mike > > On Aug 10 2011, at 01:34 , Se?n Coffey wrote: > >> CR 7047325 is an internal RFE : Internal API to improve management of direct buffers >> >> This RFE was introduced in a 6 update release and with jdk 7& jdk 8 in the open, I'm porting this change forward from the proprietary jdk6 updates. The change adds an internal API to improve the management of direct buffers. >> >> This request is for jdk 8 : http://cr.openjdk.java.net/~coffeys/7047325.jdk8/ >> >> regards, >> Sean. From Alan.Bateman at oracle.com Mon Aug 22 02:02:40 2011 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Mon, 22 Aug 2011 10:02:40 +0100 Subject: 7081796: (ch) rawtype warning in sun.nio.ch.InheritedChannel Message-ID: <4E521B30.5080100@oracle.com> Sasha's recent good work to eliminate warnings from the NIO area [1] missed one raw type warning in one source file. I suspect it was missed because he was mostly working on Windows and also because in a full build, this class is compiled implicitly when compiling other areas that don't have JAVAC_MAX_WARNINGS and JAVAC_WARNINGS_FATAL enabled. Sebastian Sickelmann ran this into this [2] when compiling this class with make/java/nio/Makefile as that enables JAVAC_WARNINGS_FATAL. The change to eliminate the raw type warning is trivial: diff --git a/src/solaris/classes/sun/nio/ch/InheritedChannel.java b/src/solaris/classes/sun/nio/ch/InheritedChannel.java --- a/src/solaris/classes/sun/nio/ch/InheritedChannel.java +++ b/src/solaris/classes/sun/nio/ch/InheritedChannel.java @@ -166,8 +166,8 @@ class InheritedChannel { // is implemented. Class paramTypes[] = { int.class }; - Constructor ctr = Reflect.lookupConstructor("java.io.FileDescriptor", - paramTypes); + Constructor ctr = Reflect.lookupConstructor("java.io.FileDescriptor", + paramTypes); Object args[] = { new Integer(fdVal) }; FileDescriptor fd = (FileDescriptor)Reflect.invoke(ctr, args); Thanks, Alan. [1] http://hg.openjdk.java.net/jdk8/tl/jdk/rev/7525866a4046 [2] http://mail.openjdk.java.net/pipermail/build-dev/2011-August/004963.html From chris.hegarty at oracle.com Mon Aug 22 02:36:10 2011 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Mon, 22 Aug 2011 10:36:10 +0100 Subject: 7081796: (ch) rawtype warning in sun.nio.ch.InheritedChannel In-Reply-To: <4E521B30.5080100@oracle.com> References: <4E521B30.5080100@oracle.com> Message-ID: <4E52230A.7020108@oracle.com> Looks fine. -Chris. On 22/08/2011 10:02, Alan Bateman wrote: > > Sasha's recent good work to eliminate warnings from the NIO area [1] > missed one raw type warning in one source file. I suspect it was missed > because he was mostly working on Windows and also because in a full > build, this class is compiled implicitly when compiling other areas that > don't have JAVAC_MAX_WARNINGS and JAVAC_WARNINGS_FATAL enabled. > Sebastian Sickelmann ran this into this [2] when compiling this class > with make/java/nio/Makefile as that enables JAVAC_WARNINGS_FATAL. > > The change to eliminate the raw type warning is trivial: > > diff --git a/src/solaris/classes/sun/nio/ch/InheritedChannel.java > b/src/solaris/classes/sun/nio/ch/InheritedChannel.java > --- a/src/solaris/classes/sun/nio/ch/InheritedChannel.java > +++ b/src/solaris/classes/sun/nio/ch/InheritedChannel.java > @@ -166,8 +166,8 @@ class InheritedChannel { > // is implemented. > > Class paramTypes[] = { int.class }; > - Constructor ctr = Reflect.lookupConstructor("java.io.FileDescriptor", > - paramTypes); > + Constructor ctr = Reflect.lookupConstructor("java.io.FileDescriptor", > + paramTypes); > Object args[] = { new Integer(fdVal) }; > FileDescriptor fd = (FileDescriptor)Reflect.invoke(ctr, args); > > Thanks, > Alan. > > [1] http://hg.openjdk.java.net/jdk8/tl/jdk/rev/7525866a4046 > [2] > http://mail.openjdk.java.net/pipermail/build-dev/2011-August/004963.html From kurchi.subhra.hazra at oracle.com Mon Aug 22 17:29:01 2011 From: kurchi.subhra.hazra at oracle.com (Kurchi Hazra) Date: Mon, 22 Aug 2011 17:29:01 -0700 Subject: Code Review Request: 7044870: TEST_BUG: java/nio/channels/DatagramChannel/SelectWhenRefused.java failed on SUSE Linux 10 Message-ID: <4E52F44D.8020409@oracle.com> Hi, Test 1 in java/nio/channels/DatagramChannel/SelectWhenRefused.java was failing on some Linux kernels. This is because the test assumes that the kernel will not bind a socket to a port that has been closed immediately. However, some linux kernels (for example, 2.6.16.60-0.62.1-smp ) are precisely doing this and the test throws a RunTime Exception. The code has been changed to not to try binding the same socket that has been immediately closed. In addition, we make sure that a port is not bound to a service already (in between the port being closed before and connected to later in the code) by checking before throwing the Exception. Submitting hg diff since I do not have an openjdk account: -bash-3.00$ hg diff diff --git a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java @@ -35,14 +35,14 @@ public class SelectWhenRefused { public class SelectWhenRefused { public static void main(String[] args) throws IOException { - DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0)); - int port = dc.socket().getLocalPort(); - dc.close(); + DatagramChannel dc1 = DatagramChannel.open().bind(new InetSocketAddress(0)); + int port = dc1.socket().getLocalPort(); + dc1.close(); // datagram sent to this address should be refused SocketAddress refuser = new InetSocketAddress(InetAddress.getLocalHost(), port); - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); + DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0)); Selector sel = Selector.open(); try { dc.configureBlocking(false); @@ -52,7 +52,15 @@ public class SelectWhenRefused { sendDatagram(dc, refuser); int n = sel.select(2000); if (n > 0) { + try { + DatagramSocket dsBindCheck=new DatagramSocket(port); + dsBindCheck.close(); throw new RuntimeException("Unexpected wakeup"); + } + catch(SocketException e) + { + //Do nothing,some other test may have used the port + } } /* Test 2: connected so ICMP port unreachable may be received */ Thanks, -- -Kurchi From chris.hegarty at oracle.com Tue Aug 23 08:08:09 2011 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Tue, 23 Aug 2011 16:08:09 +0100 Subject: Code Review Request: 7044870: TEST_BUG: java/nio/channels/DatagramChannel/SelectWhenRefused.java failed on SUSE Linux 10 In-Reply-To: <4E52F44D.8020409@oracle.com> References: <4E52F44D.8020409@oracle.com> Message-ID: <4E53C259.6010805@oracle.com> Hi Kurchi, I see your change is checking if another service is using the expected refuser port, and then ignoring any data since the test cannot be successfully run. I think this is good, but it may also be useful to defer closing of dc1 until after creation of dc. That way this issue shouldn't happen as often since dc will not reuse the refusers port. Make sense? Also, doesn't this impact on the rest of the test too? Would just catch BindException be sufficient? That's what you're expecting, right, "Address already in use"? -Chris. On 23/08/2011 01:29, Kurchi Hazra wrote: > Hi, > > > Test 1 in java/nio/channels/DatagramChannel/SelectWhenRefused.java was > failing on some Linux kernels. This is because the test assumes that the > kernel will not bind a socket to a port that has been closed immediately. > However, some linux kernels (for example, 2.6.16.60-0.62.1-smp ) are > precisely doing this and the test throws a RunTime Exception. > > The code has been changed to not to try binding the same socket that has > been immediately closed. In addition, we make sure that a port is not > bound to a service already (in between the port being closed before and > connected to later in the code) by checking before throwing the Exception. > > > Submitting hg diff since I do not have an openjdk account: > > -bash-3.00$ hg diff > diff --git > a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > @@ -35,14 +35,14 @@ public class SelectWhenRefused { > public class SelectWhenRefused { > > public static void main(String[] args) throws IOException { > - DatagramChannel dc = DatagramChannel.open().bind(new > InetSocketAddress(0)); > - int port = dc.socket().getLocalPort(); > - dc.close(); > + DatagramChannel dc1 = DatagramChannel.open().bind(new > InetSocketAddress(0)); > + int port = dc1.socket().getLocalPort(); > + dc1.close(); > > // datagram sent to this address should be refused > SocketAddress refuser = new > InetSocketAddress(InetAddress.getLocalHost(), port); > > - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); > + DatagramChannel dc = DatagramChannel.open().bind(new > InetSocketAddress(0)); > Selector sel = Selector.open(); > try { > dc.configureBlocking(false); > @@ -52,7 +52,15 @@ public class SelectWhenRefused { > sendDatagram(dc, refuser); > int n = sel.select(2000); > if (n > 0) { > + try { > + DatagramSocket dsBindCheck=new DatagramSocket(port); > + dsBindCheck.close(); > throw new RuntimeException("Unexpected wakeup"); > + } > + catch(SocketException e) > + { > + //Do nothing,some other test may have used the port > + } > } > > /* Test 2: connected so ICMP port unreachable may be received */ > > > Thanks, > From kurchi.subhra.hazra at oracle.com Tue Aug 23 11:00:48 2011 From: kurchi.subhra.hazra at oracle.com (Kurchi Hazra) Date: Tue, 23 Aug 2011 11:00:48 -0700 Subject: Code Review Request: 7044870: TEST_BUG: java/nio/channels/DatagramChannel/SelectWhenRefused.java failed on SUSE Linux 10 In-Reply-To: <4E53C259.6010805@oracle.com> References: <4E52F44D.8020409@oracle.com> <4E53C259.6010805@oracle.com> Message-ID: <4E53EAD0.8020806@oracle.com> Hi Alan, Do you have any idea why test 3 isn't failing if test 1 is failing? Thanks, Kurchi On 8/23/2011 8:08 AM, Chris Hegarty wrote: > Hi Kurchi, > > I see your change is checking if another service is using the expected > refuser port, and then ignoring any data since the test cannot be > successfully run. I think this is good, but it may also be useful to > defer closing of dc1 until after creation of dc. That way this issue > shouldn't happen as often since dc will not reuse the refusers port. > Make sense? Also, doesn't this impact on the rest of the test too? > > Would just catch BindException be sufficient? That's what you're > expecting, right, "Address already in use"? > > -Chris. > > On 23/08/2011 01:29, Kurchi Hazra wrote: >> Hi, >> >> >> Test 1 in java/nio/channels/DatagramChannel/SelectWhenRefused.java was >> failing on some Linux kernels. This is because the test assumes that the >> kernel will not bind a socket to a port that has been closed >> immediately. >> However, some linux kernels (for example, 2.6.16.60-0.62.1-smp ) are >> precisely doing this and the test throws a RunTime Exception. >> >> The code has been changed to not to try binding the same socket that has >> been immediately closed. In addition, we make sure that a port is not >> bound to a service already (in between the port being closed before and >> connected to later in the code) by checking before throwing the >> Exception. >> >> >> Submitting hg diff since I do not have an openjdk account: >> >> -bash-3.00$ hg diff >> diff --git >> a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> @@ -35,14 +35,14 @@ public class SelectWhenRefused { >> public class SelectWhenRefused { >> >> public static void main(String[] args) throws IOException { >> - DatagramChannel dc = DatagramChannel.open().bind(new >> InetSocketAddress(0)); >> - int port = dc.socket().getLocalPort(); >> - dc.close(); >> + DatagramChannel dc1 = DatagramChannel.open().bind(new >> InetSocketAddress(0)); >> + int port = dc1.socket().getLocalPort(); >> + dc1.close(); >> >> // datagram sent to this address should be refused >> SocketAddress refuser = new >> InetSocketAddress(InetAddress.getLocalHost(), port); >> >> - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); >> + DatagramChannel dc = DatagramChannel.open().bind(new >> InetSocketAddress(0)); >> Selector sel = Selector.open(); >> try { >> dc.configureBlocking(false); >> @@ -52,7 +52,15 @@ public class SelectWhenRefused { >> sendDatagram(dc, refuser); >> int n = sel.select(2000); >> if (n > 0) { >> + try { >> + DatagramSocket dsBindCheck=new DatagramSocket(port); >> + dsBindCheck.close(); >> throw new RuntimeException("Unexpected wakeup"); >> + } >> + catch(SocketException e) >> + { >> + //Do nothing,some other test may have used the port >> + } >> } >> >> /* Test 2: connected so ICMP port unreachable may be received */ >> >> >> Thanks, >> -- -Kurchi From kurchi.subhra.hazra at oracle.com Tue Aug 23 11:04:32 2011 From: kurchi.subhra.hazra at oracle.com (Kurchi Hazra) Date: Tue, 23 Aug 2011 11:04:32 -0700 Subject: Code Review Request: 7044870: TEST_BUG: java/nio/channels/DatagramChannel/SelectWhenRefused.java failed on SUSE Linux 10 In-Reply-To: <4E53C259.6010805@oracle.com> References: <4E52F44D.8020409@oracle.com> <4E53C259.6010805@oracle.com> Message-ID: <4E53EBB0.7020205@oracle.com> On 8/23/2011 8:08 AM, Chris Hegarty wrote: > Hi Kurchi, > > I see your change is checking if another service is using the expected > refuser port, and then ignoring any data since the test cannot be > successfully run. I think this is good, but it may also be useful to > defer closing of dc1 until after creation of dc. That way this issue > shouldn't happen as often since dc will not reuse the refusers port. > Make sense? Also, doesn't this impact on the rest of the test too? > > Would just catch BindException be sufficient? That's what you're > expecting, right, "Address already in use"? - I agree, it should be a BindException that I catch. Also, I will incorporate deferring of closing of dc1 until after dc is allocated a port. -Kurchi > > -Chris. > > On 23/08/2011 01:29, Kurchi Hazra wrote: >> Hi, >> >> >> Test 1 in java/nio/channels/DatagramChannel/SelectWhenRefused.java was >> failing on some Linux kernels. This is because the test assumes that the >> kernel will not bind a socket to a port that has been closed >> immediately. >> However, some linux kernels (for example, 2.6.16.60-0.62.1-smp ) are >> precisely doing this and the test throws a RunTime Exception. >> >> The code has been changed to not to try binding the same socket that has >> been immediately closed. In addition, we make sure that a port is not >> bound to a service already (in between the port being closed before and >> connected to later in the code) by checking before throwing the >> Exception. >> >> >> Submitting hg diff since I do not have an openjdk account: >> >> -bash-3.00$ hg diff >> diff --git >> a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> @@ -35,14 +35,14 @@ public class SelectWhenRefused { >> public class SelectWhenRefused { >> >> public static void main(String[] args) throws IOException { >> - DatagramChannel dc = DatagramChannel.open().bind(new >> InetSocketAddress(0)); >> - int port = dc.socket().getLocalPort(); >> - dc.close(); >> + DatagramChannel dc1 = DatagramChannel.open().bind(new >> InetSocketAddress(0)); >> + int port = dc1.socket().getLocalPort(); >> + dc1.close(); >> >> // datagram sent to this address should be refused >> SocketAddress refuser = new >> InetSocketAddress(InetAddress.getLocalHost(), port); >> >> - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); >> + DatagramChannel dc = DatagramChannel.open().bind(new >> InetSocketAddress(0)); >> Selector sel = Selector.open(); >> try { >> dc.configureBlocking(false); >> @@ -52,7 +52,15 @@ public class SelectWhenRefused { >> sendDatagram(dc, refuser); >> int n = sel.select(2000); >> if (n > 0) { >> + try { >> + DatagramSocket dsBindCheck=new DatagramSocket(port); >> + dsBindCheck.close(); >> throw new RuntimeException("Unexpected wakeup"); >> + } >> + catch(SocketException e) >> + { >> + //Do nothing,some other test may have used the port >> + } >> } >> >> /* Test 2: connected so ICMP port unreachable may be received */ >> >> >> Thanks, >> -- -Kurchi From kurchi.subhra.hazra at oracle.com Tue Aug 23 11:38:11 2011 From: kurchi.subhra.hazra at oracle.com (Kurchi Hazra) Date: Tue, 23 Aug 2011 11:38:11 -0700 Subject: Code Review Request: 7044870: TEST_BUG: java/nio/channels/DatagramChannel/SelectWhenRefused.java failed on SUSE Linux 10 In-Reply-To: <4E53EBB0.7020205@oracle.com> References: <4E52F44D.8020409@oracle.com> <4E53C259.6010805@oracle.com> <4E53EBB0.7020205@oracle.com> Message-ID: <4E53F393.3030708@oracle.com> hg diff for the updated code: -bash-3.00$ hg diff diff --git a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java @@ -34,17 +34,18 @@ import java.io.IOException; public class SelectWhenRefused { - public static void main(String[] args) throws IOException { - DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0)); - int port = dc.socket().getLocalPort(); - dc.close(); + public static void main(String[] args) throws IOException { + DatagramChannel dc1 = DatagramChannel.open().bind(new InetSocketAddress(0)); + int port = dc1.socket().getLocalPort(); + DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0)); + dc1.close(); - // datagram sent to this address should be refused - SocketAddress refuser = new InetSocketAddress(InetAddress.getLocalHost(), port); + // datagram sent to this address should be refused - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); - Selector sel = Selector.open(); - try { + SocketAddress refuser = new InetSocketAddress(InetAddress.getLocalHost(), port); + Selector sel = Selector.open(); + + try { dc.configureBlocking(false); dc.register(sel, SelectionKey.OP_READ); @@ -52,12 +53,14 @@ public class SelectWhenRefused { sendDatagram(dc, refuser); int n = sel.select(2000); if (n > 0) { + sel.selectedKeys().clear(); + DatagramSocket sock=new DatagramSocket(port); + sock.close(); throw new RuntimeException("Unexpected wakeup"); - } - - /* Test 2: connected so ICMP port unreachable may be received */ - dc.connect(refuser); - try { + } + /* Test 2: connected so ICMP port unreachable may be received */ + try { + dc.connect(refuser); sendDatagram(dc, refuser); n = sel.select(2000); if (n > 0) { @@ -80,11 +83,18 @@ public class SelectWhenRefused { throw new RuntimeException("Unexpected wakeup after disconnect"); } - } finally { + } + catch (BindException e) + { + //Do nothing, someone else has bound to this port + } + finally { sel.close(); dc.close(); } + } + static void sendDatagram(DatagramChannel dc, SocketAddress remote) throws IOException On 8/23/2011 11:04 AM, Kurchi Hazra wrote: > > > On 8/23/2011 8:08 AM, Chris Hegarty wrote: >> Hi Kurchi, >> >> I see your change is checking if another service is using the >> expected refuser port, and then ignoring any data since the test >> cannot be successfully run. I think this is good, but it may also be >> useful to defer closing of dc1 until after creation of dc. That way >> this issue shouldn't happen as often since dc will not reuse the >> refusers port. Make sense? Also, doesn't this impact on the rest of >> the test too? >> >> Would just catch BindException be sufficient? That's what you're >> expecting, right, "Address already in use"? > > > > - I agree, it should be a BindException that I catch. Also, I will > incorporate deferring of closing of dc1 until after dc is allocated a > port. > > -Kurchi > > >> >> -Chris. >> >> On 23/08/2011 01:29, Kurchi Hazra wrote: >>> Hi, >>> >>> >>> Test 1 in java/nio/channels/DatagramChannel/SelectWhenRefused.java was >>> failing on some Linux kernels. This is because the test assumes that >>> the >>> kernel will not bind a socket to a port that has been closed >>> immediately. >>> However, some linux kernels (for example, 2.6.16.60-0.62.1-smp ) are >>> precisely doing this and the test throws a RunTime Exception. >>> >>> The code has been changed to not to try binding the same socket that >>> has >>> been immediately closed. In addition, we make sure that a port is not >>> bound to a service already (in between the port being closed before and >>> connected to later in the code) by checking before throwing the >>> Exception. >>> >>> >>> Submitting hg diff since I do not have an openjdk account: >>> >>> -bash-3.00$ hg diff >>> diff --git >>> a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>> b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>> --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>> +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>> @@ -35,14 +35,14 @@ public class SelectWhenRefused { >>> public class SelectWhenRefused { >>> >>> public static void main(String[] args) throws IOException { >>> - DatagramChannel dc = DatagramChannel.open().bind(new >>> InetSocketAddress(0)); >>> - int port = dc.socket().getLocalPort(); >>> - dc.close(); >>> + DatagramChannel dc1 = DatagramChannel.open().bind(new >>> InetSocketAddress(0)); >>> + int port = dc1.socket().getLocalPort(); >>> + dc1.close(); >>> >>> // datagram sent to this address should be refused >>> SocketAddress refuser = new >>> InetSocketAddress(InetAddress.getLocalHost(), port); >>> >>> - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); >>> + DatagramChannel dc = DatagramChannel.open().bind(new >>> InetSocketAddress(0)); >>> Selector sel = Selector.open(); >>> try { >>> dc.configureBlocking(false); >>> @@ -52,7 +52,15 @@ public class SelectWhenRefused { >>> sendDatagram(dc, refuser); >>> int n = sel.select(2000); >>> if (n > 0) { >>> + try { >>> + DatagramSocket dsBindCheck=new DatagramSocket(port); >>> + dsBindCheck.close(); >>> throw new RuntimeException("Unexpected wakeup"); >>> + } >>> + catch(SocketException e) >>> + { >>> + //Do nothing,some other test may have used the port >>> + } >>> } >>> >>> /* Test 2: connected so ICMP port unreachable may be received */ >>> >>> >>> Thanks, >>> > -- -Kurchi From chris.hegarty at oracle.com Tue Aug 23 13:36:07 2011 From: chris.hegarty at oracle.com (chris hegarty) Date: Tue, 23 Aug 2011 21:36:07 +0100 Subject: Code Review Request: 7044870: TEST_BUG: java/nio/channels/DatagramChannel/SelectWhenRefused.java failed on SUSE Linux 10 In-Reply-To: <4E53F393.3030708@oracle.com> References: <4E52F44D.8020409@oracle.com> <4E53C259.6010805@oracle.com> <4E53EBB0.7020205@oracle.com> <4E53F393.3030708@oracle.com> Message-ID: <4E540F37.5020802@oracle.com> I'm not sure if it is the output of hg diff or your editor, but there appears to be stylistic issues. - removal of four space indentation of main method and several following declarations - open curly brace for finally/catch should be on same line - finally clause should start on the same line as the closing curly brace -Chris. There seems to be On 23/08/2011 19:38, Kurchi Hazra wrote: > hg diff for the updated code: > > -bash-3.00$ hg diff > diff --git > a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > @@ -34,17 +34,18 @@ import java.io.IOException; > > public class SelectWhenRefused { > > - public static void main(String[] args) throws IOException { > - DatagramChannel dc = DatagramChannel.open().bind(new > InetSocketAddress(0)); > - int port = dc.socket().getLocalPort(); > - dc.close(); > + public static void main(String[] args) throws IOException { > + DatagramChannel dc1 = DatagramChannel.open().bind(new > InetSocketAddress(0)); > + int port = dc1.socket().getLocalPort(); > + DatagramChannel dc = DatagramChannel.open().bind(new > InetSocketAddress(0)); > + dc1.close(); > > - // datagram sent to this address should be refused > - SocketAddress refuser = new > InetSocketAddress(InetAddress.getLocalHost(), port); > + // datagram sent to this address should be refused > > - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); > - Selector sel = Selector.open(); > - try { > + SocketAddress refuser = new > InetSocketAddress(InetAddress.getLocalHost(), port); > + Selector sel = Selector.open(); > + > + try { > dc.configureBlocking(false); > dc.register(sel, SelectionKey.OP_READ); > > @@ -52,12 +53,14 @@ public class SelectWhenRefused { > sendDatagram(dc, refuser); > int n = sel.select(2000); > if (n > 0) { > + sel.selectedKeys().clear(); > + DatagramSocket sock=new DatagramSocket(port); > + sock.close(); > throw new RuntimeException("Unexpected wakeup"); > - } > - > - /* Test 2: connected so ICMP port unreachable may be > received */ > - dc.connect(refuser); > - try { > + } > + /* Test 2: connected so ICMP port > unreachable may be received */ > + try { > + dc.connect(refuser); > sendDatagram(dc, refuser); > n = sel.select(2000); > if (n > 0) { > @@ -80,11 +83,18 @@ public class SelectWhenRefused { > throw new RuntimeException("Unexpected wakeup after > disconnect"); > } > > - } finally { > + } > + catch (BindException e) > + { > + //Do nothing, someone else has bound to this port > + } > + finally { > sel.close(); > dc.close(); > } > + > } > + > > static void sendDatagram(DatagramChannel dc, SocketAddress remote) > throws IOException > > > On 8/23/2011 11:04 AM, Kurchi Hazra wrote: >> >> >> On 8/23/2011 8:08 AM, Chris Hegarty wrote: >>> Hi Kurchi, >>> >>> I see your change is checking if another service is using the >>> expected refuser port, and then ignoring any data since the test >>> cannot be successfully run. I think this is good, but it may also be >>> useful to defer closing of dc1 until after creation of dc. That way >>> this issue shouldn't happen as often since dc will not reuse the >>> refusers port. Make sense? Also, doesn't this impact on the rest of >>> the test too? >>> >>> Would just catch BindException be sufficient? That's what you're >>> expecting, right, "Address already in use"? >> >> >> >> - I agree, it should be a BindException that I catch. Also, I will >> incorporate deferring of closing of dc1 until after dc is allocated a >> port. >> >> -Kurchi >> >> >>> >>> -Chris. >>> >>> On 23/08/2011 01:29, Kurchi Hazra wrote: >>>> Hi, >>>> >>>> >>>> Test 1 in java/nio/channels/DatagramChannel/SelectWhenRefused.java was >>>> failing on some Linux kernels. This is because the test assumes >>>> that the >>>> kernel will not bind a socket to a port that has been closed >>>> immediately. >>>> However, some linux kernels (for example, 2.6.16.60-0.62.1-smp ) are >>>> precisely doing this and the test throws a RunTime Exception. >>>> >>>> The code has been changed to not to try binding the same socket >>>> that has >>>> been immediately closed. In addition, we make sure that a port is not >>>> bound to a service already (in between the port being closed before >>>> and >>>> connected to later in the code) by checking before throwing the >>>> Exception. >>>> >>>> >>>> Submitting hg diff since I do not have an openjdk account: >>>> >>>> -bash-3.00$ hg diff >>>> diff --git >>>> a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>> b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>> --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>> +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>> @@ -35,14 +35,14 @@ public class SelectWhenRefused { >>>> public class SelectWhenRefused { >>>> >>>> public static void main(String[] args) throws IOException { >>>> - DatagramChannel dc = DatagramChannel.open().bind(new >>>> InetSocketAddress(0)); >>>> - int port = dc.socket().getLocalPort(); >>>> - dc.close(); >>>> + DatagramChannel dc1 = DatagramChannel.open().bind(new >>>> InetSocketAddress(0)); >>>> + int port = dc1.socket().getLocalPort(); >>>> + dc1.close(); >>>> >>>> // datagram sent to this address should be refused >>>> SocketAddress refuser = new >>>> InetSocketAddress(InetAddress.getLocalHost(), port); >>>> >>>> - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); >>>> + DatagramChannel dc = DatagramChannel.open().bind(new >>>> InetSocketAddress(0)); >>>> Selector sel = Selector.open(); >>>> try { >>>> dc.configureBlocking(false); >>>> @@ -52,7 +52,15 @@ public class SelectWhenRefused { >>>> sendDatagram(dc, refuser); >>>> int n = sel.select(2000); >>>> if (n > 0) { >>>> + try { >>>> + DatagramSocket dsBindCheck=new DatagramSocket(port); >>>> + dsBindCheck.close(); >>>> throw new RuntimeException("Unexpected wakeup"); >>>> + } >>>> + catch(SocketException e) >>>> + { >>>> + //Do nothing,some other test may have used the port >>>> + } >>>> } >>>> >>>> /* Test 2: connected so ICMP port unreachable may be received */ >>>> >>>> >>>> Thanks, >>>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20110823/c9d2cbf8/attachment.html From kurchi.subhra.hazra at oracle.com Tue Aug 23 21:04:36 2011 From: kurchi.subhra.hazra at oracle.com (Kurchi Hazra) Date: Tue, 23 Aug 2011 21:04:36 -0700 Subject: Code Review Request: 7044870: TEST_BUG: java/nio/channels/DatagramChannel/SelectWhenRefused.java failed on SUSE Linux 10 In-Reply-To: <4E540F37.5020802@oracle.com> References: <4E52F44D.8020409@oracle.com> <4E53C259.6010805@oracle.com> <4E53EBB0.7020205@oracle.com> <4E53F393.3030708@oracle.com> <4E540F37.5020802@oracle.com> Message-ID: <4E547854.2010903@oracle.com> Hi, The updated code: -bash-3.00$ hg diff *** failed to import extension rebase: No module named rebase diff --git a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java @@ -35,14 +35,15 @@ public class SelectWhenRefused { public class SelectWhenRefused { public static void main(String[] args) throws IOException { - DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0)); - int port = dc.socket().getLocalPort(); - dc.close(); + DatagramChannel dc1 = DatagramChannel.open().bind(new InetSocketAddress(0)); + int port = dc1.socket().getLocalPort(); // datagram sent to this address should be refused SocketAddress refuser = new InetSocketAddress(InetAddress.getLocalHost(), port); - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); + DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0)); + dc1.close(); + Selector sel = Selector.open(); try { dc.configureBlocking(false); @@ -52,6 +53,9 @@ public class SelectWhenRefused { sendDatagram(dc, refuser); int n = sel.select(2000); if (n > 0) { + sel.selectedKeys().clear(); + DatagramSocket sock=new DatagramSocket(port); + sock.close(); throw new RuntimeException("Unexpected wakeup"); } @@ -80,7 +84,11 @@ public class SelectWhenRefused { throw new RuntimeException("Unexpected wakeup after disconnect"); } - } finally { + } catch(BindException e) { + + //Do nothing, some other test has used this port + + } finally { sel.close(); dc.close(); } Thanks, Kurchi On 8/23/2011 1:36 PM, chris hegarty wrote: > I'm not sure if it is the output of hg diff or your editor, but there > appears to be stylistic issues. > > - removal of four space indentation of main method and several > following declarations > - open curly brace for finally/catch should be on same line > - finally clause should start on the same line as the closing curly > brace > > -Chris. > > There seems to be > > On 23/08/2011 19:38, Kurchi Hazra wrote: >> hg diff for the updated code: >> >> -bash-3.00$ hg diff >> diff --git >> a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >> @@ -34,17 +34,18 @@ import java.io.IOException; >> >> public class SelectWhenRefused { >> >> - public static void main(String[] args) throws IOException { >> - DatagramChannel dc = DatagramChannel.open().bind(new >> InetSocketAddress(0)); >> - int port = dc.socket().getLocalPort(); >> - dc.close(); >> + public static void main(String[] args) throws IOException { >> + DatagramChannel dc1 = DatagramChannel.open().bind(new >> InetSocketAddress(0)); >> + int port = dc1.socket().getLocalPort(); >> + DatagramChannel dc = DatagramChannel.open().bind(new >> InetSocketAddress(0)); >> + dc1.close(); >> >> - // datagram sent to this address should be refused >> - SocketAddress refuser = new >> InetSocketAddress(InetAddress.getLocalHost(), port); >> + // datagram sent to this address should be refused >> >> - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); >> - Selector sel = Selector.open(); >> - try { >> + SocketAddress refuser = new >> InetSocketAddress(InetAddress.getLocalHost(), port); >> + Selector sel = Selector.open(); >> + >> + try { >> dc.configureBlocking(false); >> dc.register(sel, SelectionKey.OP_READ); >> >> @@ -52,12 +53,14 @@ public class SelectWhenRefused { >> sendDatagram(dc, refuser); >> int n = sel.select(2000); >> if (n > 0) { >> + sel.selectedKeys().clear(); >> + DatagramSocket sock=new DatagramSocket(port); >> + sock.close(); >> throw new RuntimeException("Unexpected wakeup"); >> - } >> - >> - /* Test 2: connected so ICMP port unreachable may be >> received */ >> - dc.connect(refuser); >> - try { >> + } >> + /* Test 2: connected so ICMP port >> unreachable may be received */ >> + try { >> + dc.connect(refuser); >> sendDatagram(dc, refuser); >> n = sel.select(2000); >> if (n > 0) { >> @@ -80,11 +83,18 @@ public class SelectWhenRefused { >> throw new RuntimeException("Unexpected wakeup after >> disconnect"); >> } >> >> - } finally { >> + } >> + catch (BindException e) >> + { >> + //Do nothing, someone else has bound to this port >> + } >> + finally { >> sel.close(); >> dc.close(); >> } >> + >> } >> + >> >> static void sendDatagram(DatagramChannel dc, SocketAddress remote) >> throws IOException >> >> >> On 8/23/2011 11:04 AM, Kurchi Hazra wrote: >>> >>> >>> On 8/23/2011 8:08 AM, Chris Hegarty wrote: >>>> Hi Kurchi, >>>> >>>> I see your change is checking if another service is using the >>>> expected refuser port, and then ignoring any data since the test >>>> cannot be successfully run. I think this is good, but it may also >>>> be useful to defer closing of dc1 until after creation of dc. That >>>> way this issue shouldn't happen as often since dc will not reuse >>>> the refusers port. Make sense? Also, doesn't this impact on the >>>> rest of the test too? >>>> >>>> Would just catch BindException be sufficient? That's what you're >>>> expecting, right, "Address already in use"? >>> >>> >>> >>> - I agree, it should be a BindException that I catch. Also, I will >>> incorporate deferring of closing of dc1 until after dc is allocated >>> a port. >>> >>> -Kurchi >>> >>> >>>> >>>> -Chris. >>>> >>>> On 23/08/2011 01:29, Kurchi Hazra wrote: >>>>> Hi, >>>>> >>>>> >>>>> Test 1 in java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>>> was >>>>> failing on some Linux kernels. This is because the test assumes >>>>> that the >>>>> kernel will not bind a socket to a port that has been closed >>>>> immediately. >>>>> However, some linux kernels (for example, 2.6.16.60-0.62.1-smp ) are >>>>> precisely doing this and the test throws a RunTime Exception. >>>>> >>>>> The code has been changed to not to try binding the same socket >>>>> that has >>>>> been immediately closed. In addition, we make sure that a port is not >>>>> bound to a service already (in between the port being closed >>>>> before and >>>>> connected to later in the code) by checking before throwing the >>>>> Exception. >>>>> >>>>> >>>>> Submitting hg diff since I do not have an openjdk account: >>>>> >>>>> -bash-3.00$ hg diff >>>>> diff --git >>>>> a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>>> b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>>> --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>>> +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>>> @@ -35,14 +35,14 @@ public class SelectWhenRefused { >>>>> public class SelectWhenRefused { >>>>> >>>>> public static void main(String[] args) throws IOException { >>>>> - DatagramChannel dc = DatagramChannel.open().bind(new >>>>> InetSocketAddress(0)); >>>>> - int port = dc.socket().getLocalPort(); >>>>> - dc.close(); >>>>> + DatagramChannel dc1 = DatagramChannel.open().bind(new >>>>> InetSocketAddress(0)); >>>>> + int port = dc1.socket().getLocalPort(); >>>>> + dc1.close(); >>>>> >>>>> // datagram sent to this address should be refused >>>>> SocketAddress refuser = new >>>>> InetSocketAddress(InetAddress.getLocalHost(), port); >>>>> >>>>> - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); >>>>> + DatagramChannel dc = DatagramChannel.open().bind(new >>>>> InetSocketAddress(0)); >>>>> Selector sel = Selector.open(); >>>>> try { >>>>> dc.configureBlocking(false); >>>>> @@ -52,7 +52,15 @@ public class SelectWhenRefused { >>>>> sendDatagram(dc, refuser); >>>>> int n = sel.select(2000); >>>>> if (n > 0) { >>>>> + try { >>>>> + DatagramSocket dsBindCheck=new DatagramSocket(port); >>>>> + dsBindCheck.close(); >>>>> throw new RuntimeException("Unexpected wakeup"); >>>>> + } >>>>> + catch(SocketException e) >>>>> + { >>>>> + //Do nothing,some other test may have used the port >>>>> + } >>>>> } >>>>> >>>>> /* Test 2: connected so ICMP port unreachable may be received */ >>>>> >>>>> >>>>> Thanks, >>>>> >>> >> -- -Kurchi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20110823/153dcd16/attachment-0001.html From kurchi.subhra.hazra at oracle.com Thu Aug 25 06:57:44 2011 From: kurchi.subhra.hazra at oracle.com (Kurchi Hazra) Date: Thu, 25 Aug 2011 06:57:44 -0700 Subject: Code Review Request: 7044870: TEST_BUG: java/nio/channels/DatagramChannel/SelectWhenRefused.java failed on SUSE Linux 10 In-Reply-To: <4E547854.2010903@oracle.com> References: <4E52F44D.8020409@oracle.com> <4E53C259.6010805@oracle.com> <4E53EBB0.7020205@oracle.com> <4E53F393.3030708@oracle.com> <4E540F37.5020802@oracle.com> <4E547854.2010903@oracle.com> Message-ID: <4E5654D8.2060700@oracle.com> Hi, The update code with some more styling/comment changes: diff --git a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 6935563 + * @bug 6935563 7044870 * @summary Test that Selector does not select an unconnected DatagramChannel when * ICMP port unreachable received */ @@ -35,14 +35,15 @@ public class SelectWhenRefused { public class SelectWhenRefused { public static void main(String[] args) throws IOException { - DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0)); - int port = dc.socket().getLocalPort(); - dc.close(); + DatagramChannel dc1 = DatagramChannel.open().bind(new InetSocketAddress(0)); + int port = dc1.socket().getLocalPort(); // datagram sent to this address should be refused SocketAddress refuser = new InetSocketAddress(InetAddress.getLocalHost(), port); - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); + DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0)); + dc1.close(); + Selector sel = Selector.open(); try { dc.configureBlocking(false); @@ -52,6 +53,11 @@ public class SelectWhenRefused { sendDatagram(dc, refuser); int n = sel.select(2000); if (n > 0) { + sel.selectedKeys().clear(); + //BindException will be thrown if another service is using + //our expected refuser port, cannot run just exit. + DatagramSocket sock=new DatagramSocket(port); + sock.close(); throw new RuntimeException("Unexpected wakeup"); } @@ -80,6 +86,8 @@ public class SelectWhenRefused { throw new RuntimeException("Unexpected wakeup after disconnect"); } + } catch(BindException e) { + //Do nothing, some other test has used this port } finally { sel.close(); dc.close(); Thanks, Kurchi On 8/23/2011 9:04 PM, Kurchi Hazra wrote: > Hi, > > The updated code: > > -bash-3.00$ hg diff > *** failed to import extension rebase: No module named rebase > diff --git > a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java > @@ -35,14 +35,15 @@ public class SelectWhenRefused { > public class SelectWhenRefused { > > public static void main(String[] args) throws IOException { > - DatagramChannel dc = DatagramChannel.open().bind(new > InetSocketAddress(0)); > - int port = dc.socket().getLocalPort(); > - dc.close(); > + DatagramChannel dc1 = DatagramChannel.open().bind(new > InetSocketAddress(0)); > + int port = dc1.socket().getLocalPort(); > > // datagram sent to this address should be refused > SocketAddress refuser = new > InetSocketAddress(InetAddress.getLocalHost(), port); > > - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); > + DatagramChannel dc = DatagramChannel.open().bind(new > InetSocketAddress(0)); > + dc1.close(); > + > Selector sel = Selector.open(); > try { > dc.configureBlocking(false); > @@ -52,6 +53,9 @@ public class SelectWhenRefused { > sendDatagram(dc, refuser); > int n = sel.select(2000); > if (n > 0) { > + sel.selectedKeys().clear(); > + DatagramSocket sock=new DatagramSocket(port); > + sock.close(); > throw new RuntimeException("Unexpected wakeup"); > } > > @@ -80,7 +84,11 @@ public class SelectWhenRefused { > throw new RuntimeException("Unexpected wakeup after > disconnect"); > } > > - } finally { > + } catch(BindException e) { > + > + //Do nothing, some other test has used this port > + > + } finally { > sel.close(); > dc.close(); > } > > > > Thanks, > > Kurchi > > On 8/23/2011 1:36 PM, chris hegarty wrote: >> I'm not sure if it is the output of hg diff or your editor, but there >> appears to be stylistic issues. >> >> - removal of four space indentation of main method and several >> following declarations >> - open curly brace for finally/catch should be on same line >> - finally clause should start on the same line as the closing curly >> brace >> >> -Chris. >> >> There seems to be >> >> On 23/08/2011 19:38, Kurchi Hazra wrote: >>> hg diff for the updated code: >>> >>> -bash-3.00$ hg diff >>> diff --git >>> a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>> b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>> --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>> +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>> @@ -34,17 +34,18 @@ import java.io.IOException; >>> >>> public class SelectWhenRefused { >>> >>> - public static void main(String[] args) throws IOException { >>> - DatagramChannel dc = DatagramChannel.open().bind(new >>> InetSocketAddress(0)); >>> - int port = dc.socket().getLocalPort(); >>> - dc.close(); >>> + public static void main(String[] args) throws IOException { >>> + DatagramChannel dc1 = DatagramChannel.open().bind(new >>> InetSocketAddress(0)); >>> + int port = dc1.socket().getLocalPort(); >>> + DatagramChannel dc = DatagramChannel.open().bind(new >>> InetSocketAddress(0)); >>> + dc1.close(); >>> >>> - // datagram sent to this address should be refused >>> - SocketAddress refuser = new >>> InetSocketAddress(InetAddress.getLocalHost(), port); >>> + // datagram sent to this address should be refused >>> >>> - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); >>> - Selector sel = Selector.open(); >>> - try { >>> + SocketAddress refuser = new >>> InetSocketAddress(InetAddress.getLocalHost(), port); >>> + Selector sel = Selector.open(); >>> + >>> + try { >>> dc.configureBlocking(false); >>> dc.register(sel, SelectionKey.OP_READ); >>> >>> @@ -52,12 +53,14 @@ public class SelectWhenRefused { >>> sendDatagram(dc, refuser); >>> int n = sel.select(2000); >>> if (n > 0) { >>> + sel.selectedKeys().clear(); >>> + DatagramSocket sock=new DatagramSocket(port); >>> + sock.close(); >>> throw new RuntimeException("Unexpected wakeup"); >>> - } >>> - >>> - /* Test 2: connected so ICMP port unreachable may be >>> received */ >>> - dc.connect(refuser); >>> - try { >>> + } >>> + /* Test 2: connected so ICMP port >>> unreachable may be received */ >>> + try { >>> + dc.connect(refuser); >>> sendDatagram(dc, refuser); >>> n = sel.select(2000); >>> if (n > 0) { >>> @@ -80,11 +83,18 @@ public class SelectWhenRefused { >>> throw new RuntimeException("Unexpected wakeup after >>> disconnect"); >>> } >>> >>> - } finally { >>> + } >>> + catch (BindException e) >>> + { >>> + //Do nothing, someone else has bound to this port >>> + } >>> + finally { >>> sel.close(); >>> dc.close(); >>> } >>> + >>> } >>> + >>> >>> static void sendDatagram(DatagramChannel dc, SocketAddress remote) >>> throws IOException >>> >>> >>> On 8/23/2011 11:04 AM, Kurchi Hazra wrote: >>>> >>>> >>>> On 8/23/2011 8:08 AM, Chris Hegarty wrote: >>>>> Hi Kurchi, >>>>> >>>>> I see your change is checking if another service is using the >>>>> expected refuser port, and then ignoring any data since the test >>>>> cannot be successfully run. I think this is good, but it may also >>>>> be useful to defer closing of dc1 until after creation of dc. That >>>>> way this issue shouldn't happen as often since dc will not reuse >>>>> the refusers port. Make sense? Also, doesn't this impact on the >>>>> rest of the test too? >>>>> >>>>> Would just catch BindException be sufficient? That's what you're >>>>> expecting, right, "Address already in use"? >>>> >>>> >>>> >>>> - I agree, it should be a BindException that I catch. Also, I will >>>> incorporate deferring of closing of dc1 until after dc is allocated >>>> a port. >>>> >>>> -Kurchi >>>> >>>> >>>>> >>>>> -Chris. >>>>> >>>>> On 23/08/2011 01:29, Kurchi Hazra wrote: >>>>>> Hi, >>>>>> >>>>>> >>>>>> Test 1 in >>>>>> java/nio/channels/DatagramChannel/SelectWhenRefused.java was >>>>>> failing on some Linux kernels. This is because the test assumes >>>>>> that the >>>>>> kernel will not bind a socket to a port that has been closed >>>>>> immediately. >>>>>> However, some linux kernels (for example, 2.6.16.60-0.62.1-smp ) are >>>>>> precisely doing this and the test throws a RunTime Exception. >>>>>> >>>>>> The code has been changed to not to try binding the same socket >>>>>> that has >>>>>> been immediately closed. In addition, we make sure that a port is >>>>>> not >>>>>> bound to a service already (in between the port being closed >>>>>> before and >>>>>> connected to later in the code) by checking before throwing the >>>>>> Exception. >>>>>> >>>>>> >>>>>> Submitting hg diff since I do not have an openjdk account: >>>>>> >>>>>> -bash-3.00$ hg diff >>>>>> diff --git >>>>>> a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>>>> b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>>>> --- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>>>> +++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java >>>>>> @@ -35,14 +35,14 @@ public class SelectWhenRefused { >>>>>> public class SelectWhenRefused { >>>>>> >>>>>> public static void main(String[] args) throws IOException { >>>>>> - DatagramChannel dc = DatagramChannel.open().bind(new >>>>>> InetSocketAddress(0)); >>>>>> - int port = dc.socket().getLocalPort(); >>>>>> - dc.close(); >>>>>> + DatagramChannel dc1 = DatagramChannel.open().bind(new >>>>>> InetSocketAddress(0)); >>>>>> + int port = dc1.socket().getLocalPort(); >>>>>> + dc1.close(); >>>>>> >>>>>> // datagram sent to this address should be refused >>>>>> SocketAddress refuser = new >>>>>> InetSocketAddress(InetAddress.getLocalHost(), port); >>>>>> >>>>>> - dc = DatagramChannel.open().bind(new InetSocketAddress(0)); >>>>>> + DatagramChannel dc = DatagramChannel.open().bind(new >>>>>> InetSocketAddress(0)); >>>>>> Selector sel = Selector.open(); >>>>>> try { >>>>>> dc.configureBlocking(false); >>>>>> @@ -52,7 +52,15 @@ public class SelectWhenRefused { >>>>>> sendDatagram(dc, refuser); >>>>>> int n = sel.select(2000); >>>>>> if (n > 0) { >>>>>> + try { >>>>>> + DatagramSocket dsBindCheck=new DatagramSocket(port); >>>>>> + dsBindCheck.close(); >>>>>> throw new RuntimeException("Unexpected wakeup"); >>>>>> + } >>>>>> + catch(SocketException e) >>>>>> + { >>>>>> + //Do nothing,some other test may have used the port >>>>>> + } >>>>>> } >>>>>> >>>>>> /* Test 2: connected so ICMP port unreachable may be received */ >>>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>> >>> > > -- > -Kurchi -- -Kurchi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20110825/21ee06ee/attachment-0001.html From Alan.Bateman at oracle.com Thu Aug 25 07:33:04 2011 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 25 Aug 2011 15:33:04 +0100 Subject: Code Review Request: 7044870: TEST_BUG: java/nio/channels/DatagramChannel/SelectWhenRefused.java failed on SUSE Linux 10 In-Reply-To: <4E5654D8.2060700@oracle.com> References: <4E52F44D.8020409@oracle.com> <4E53C259.6010805@oracle.com> <4E53EBB0.7020205@oracle.com> <4E53F393.3030708@oracle.com> <4E540F37.5020802@oracle.com> <4E547854.2010903@oracle.com> <4E5654D8.2060700@oracle.com> Message-ID: <4E565D20.2040206@oracle.com> Kurchi Hazra wrote: > Hi, > > The update code with some more styling/comment changes: The patch looks okay to me. Minor nit is that the comments should keep the existing style. Also these tests rarely use DatagramSocket and where they do then they use "ds" rather than "sock". Otherwise thanks for taking this one. -Alan. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20110825/38e26dd5/attachment.html From chris.hegarty at oracle.com Thu Aug 25 08:16:17 2011 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Thu, 25 Aug 2011 16:16:17 +0100 Subject: Code Review Request: 7044870: TEST_BUG: java/nio/channels/DatagramChannel/SelectWhenRefused.java failed on SUSE Linux 10 In-Reply-To: <4E565D20.2040206@oracle.com> References: <4E52F44D.8020409@oracle.com> <4E53C259.6010805@oracle.com> <4E53EBB0.7020205@oracle.com> <4E53F393.3030708@oracle.com> <4E540F37.5020802@oracle.com> <4E547854.2010903@oracle.com> <4E5654D8.2060700@oracle.com> <4E565D20.2040206@oracle.com> Message-ID: <4E566741.3060802@oracle.com> To close the loop on this one. I took Kurchi's patch, incorporated Alan's comments, and pushed it. JDK8 changeset: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/c9e78769c0da -Chris. On 25/08/2011 15:33, Alan Bateman wrote: > Kurchi Hazra wrote: >> Hi, >> >> The update code with some more styling/comment changes: > The patch looks okay to me. Minor nit is that the comments should keep > the existing style. Also these tests rarely use DatagramSocket and where > they do then they use "ds" rather than "sock". Otherwise thanks for > taking this one. > > -Alan. > From kurchi.subhra.hazra at oracle.com Fri Aug 26 13:06:30 2011 From: kurchi.subhra.hazra at oracle.com (Kurchi Hazra) Date: Fri, 26 Aug 2011 13:06:30 -0700 Subject: Code Review Request: 7060243: (dc) Multicasting tests fail on Windows XP if IPv6 is enabled Message-ID: <4E57FCC6.8000504@oracle.com> Hi, java/nio/channels/DatagramChannel/BasicMulticastTests.java and java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java were throwing an UnSupportedOperationException on Windows XP 32 bit, with an IPV6 stack, since NIO Channels do not support the old stack. Both these testcases rely on the InetAddresses returned by probe() in test/java/nio/channels/DatagramChannel/NetworkConfiguration.java. Hence, the fix was to modify probe() in NetworkConfiguration.java to not return the list of IPV6 InetAddresses if the OS is Windows and the version is lower than 6. Submitting hg diff since I do not have an openjdk account: diff --git a/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java b/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java --- a/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java +++ b/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java @@ -27,6 +27,7 @@ import java.io.IOException; /** * Helper class for multicasting tests. + * @bug 7060243 */ class NetworkConfiguration { @@ -62,7 +63,7 @@ class NetworkConfiguration { new HashMap>(); Map> ip6Interfaces = new HashMap>(); - + boolean ipv6Supported= isIpv6Supported(); // find the interfaces that support IPv4 and IPv6 List nifs = Collections .list(NetworkInterface.getNetworkInterfaces()); @@ -70,7 +71,6 @@ class NetworkConfiguration { // ignore intertaces that are down or don't support multicast if (!nif.isUp() || !nif.supportsMulticast() || nif.isLoopback()) continue; - List addrs = Collections.list(nif.getInetAddresses()); for (InetAddress addr: addrs) { if (!addr.isAnyLocalAddress()) { @@ -81,7 +81,7 @@ class NetworkConfiguration { } list.add(addr); ip4Interfaces.put(nif, list); - } else if (addr instanceof Inet6Address) { + } else if ( ipv6Supported&& (addr instanceof Inet6Address)) { List list = ip6Interfaces.get(nif); if (list == null) { list = new LinkedList(); @@ -94,4 +94,16 @@ class NetworkConfiguration { } return new NetworkConfiguration(ip4Interfaces, ip6Interfaces); } + + private static boolean isIpv6Supported() + { + boolean returnVal=true; + + /*IPV6 is not supported for Windows XP/Server 2003*/ + if((System.getProperty("os.name").contains("Windows"))&& (Float.valueOf(System.getProperty("os.version"))<6)) { + returnVal=false; + } + + return returnVal; + } } Thanks, -- -Kurchi From Alan.Bateman at oracle.com Fri Aug 26 13:40:51 2011 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 26 Aug 2011 21:40:51 +0100 Subject: Code Review Request: 7060243: (dc) Multicasting tests fail on Windows XP if IPv6 is enabled In-Reply-To: <4E57FCC6.8000504@oracle.com> References: <4E57FCC6.8000504@oracle.com> Message-ID: <4E5804D3.1000700@oracle.com> Kurchi Hazra wrote: > > Hi, > > java/nio/channels/DatagramChannel/BasicMulticastTests.java and > java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java were > throwing an UnSupportedOperationException on Windows XP 32 bit, > with an IPV6 stack, since NIO Channels do not support the old stack. > Both these testcases rely on the InetAddresses returned by probe() in > test/java/nio/channels/DatagramChannel/NetworkConfiguration.java. > Hence, the fix was to modify probe() in NetworkConfiguration.java to > not return the list of IPV6 InetAddresses if the OS is Windows and the > version is lower than 6. Thanks Kurchi, this was an oversight in the test as IPv6 isn't enabled on Windows XP/2003 by default. Changing the probe method filter out IPv6 addresses is right and thanks for doing that. A couple of minor nits, is that this is a helper class used by the tests and so shouldn't have the @bug tag. Also the coding style in isIpv6Supported is a bit inconsistent with the the rest of the tests. I can fix these up before pushing the fix and I'll push it list you as contributer. -Alan. From kurchi.subhra.hazra at oracle.com Fri Aug 26 13:47:58 2011 From: kurchi.subhra.hazra at oracle.com (Kurchi Hazra) Date: Fri, 26 Aug 2011 13:47:58 -0700 Subject: Code Review Request: 7060243: (dc) Multicasting tests fail on Windows XP if IPv6 is enabled In-Reply-To: <4E5804D3.1000700@oracle.com> References: <4E57FCC6.8000504@oracle.com> <4E5804D3.1000700@oracle.com> Message-ID: <4E58067E.4020408@oracle.com> On 8/26/2011 1:40 PM, Alan Bateman wrote: > A couple of minor nits, is that this is a helper class used by the > tests and so shouldn't have the @bug tag. - I see. > Also the coding style in isIpv6Supported is a bit inconsistent with > the the rest of the tests. I can fix these up before pushing the fix > and I'll push it list you as contributer. > > Thanks in advance for pushing this in. I will take a look at the changeset once this is done, to see where all I was inconsistent. - Kurchi From Alan.Bateman at oracle.com Sat Aug 27 06:18:00 2011 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Sat, 27 Aug 2011 14:18:00 +0100 Subject: 7060790: (fs) FileSystem.newWatchService error message confusing when maximum inotify descriptors reached Message-ID: <4E58EE88.5070603@oracle.com> This is a minor tweak to the WatchService implementation on Linux so that it prints a more useful message in the event that the system is out of inotify instances. The errno when inotify_init fails in this case is EMFILE and so the IOException is thrown with "Too many open files" which can be confused with running out of file descriptors. The patch simple translates this error into a more useful message to aid diagnosing the issue. I don't propose to include a test with this as tests that check exception message tend to be too fragile. Thanks, Alan. diff --git a/src/solaris/classes/sun/nio/fs/LinuxWatchService.java b/src/solaris/classes/sun/nio/fs/LinuxWatchService.java --- a/src/solaris/classes/sun/nio/fs/LinuxWatchService.java +++ b/src/solaris/classes/sun/nio/fs/LinuxWatchService.java @@ -58,7 +58,10 @@ class LinuxWatchService try { ifd = inotifyInit(); } catch (UnixException x) { - throw new IOException(x.errorString()); + String msg = (x.errno() == EMFILE) ? + "User limit of inotify instances reached or too many open files" : + x.errorString(); + throw new IOException(msg); } // configure inotify to be non-blocking diff --git a/src/solaris/native/sun/nio/fs/genUnixConstants.c b/src/solaris/native/sun/nio/fs/genUnixConstants.c --- a/src/solaris/native/sun/nio/fs/genUnixConstants.c +++ b/src/solaris/native/sun/nio/fs/genUnixConstants.c @@ -108,6 +108,7 @@ int main(int argc, const char* argv[]) { DEF(EROFS); DEF(ENODATA); DEF(ERANGE); + DEF(EMFILE); // flags used with openat/unlinkat/etc. #if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_REMOVEDIR) From forax at univ-mlv.fr Sat Aug 27 06:36:01 2011 From: forax at univ-mlv.fr (=?ISO-8859-1?Q?R=E9mi_Forax?=) Date: Sat, 27 Aug 2011 15:36:01 +0200 Subject: 7060790: (fs) FileSystem.newWatchService error message confusing when maximum inotify descriptors reached In-Reply-To: <4E58EE88.5070603@oracle.com> References: <4E58EE88.5070603@oracle.com> Message-ID: <4E58F2C1.2090605@univ-mlv.fr> On 08/27/2011 03:18 PM, Alan Bateman wrote: > > This is a minor tweak to the WatchService implementation on Linux so > that it prints a more useful message in the event that the system is > out of inotify instances. The errno when inotify_init fails in this > case is EMFILE and so the IOException is thrown with "Too many open > files" which can be confused with running out of file descriptors. The > patch simple translates this error into a more useful message to aid > diagnosing the issue. I don't propose to include a test with this as > tests that check exception message tend to be too fragile. > > Thanks, > Alan. Hi Alan, patch looks good. R?mi > > > diff --git a/src/solaris/classes/sun/nio/fs/LinuxWatchService.java > b/src/solaris/classes/sun/nio/fs/LinuxWatchService.java > --- a/src/solaris/classes/sun/nio/fs/LinuxWatchService.java > +++ b/src/solaris/classes/sun/nio/fs/LinuxWatchService.java > @@ -58,7 +58,10 @@ class LinuxWatchService > try { > ifd = inotifyInit(); > } catch (UnixException x) { > - throw new IOException(x.errorString()); > + String msg = (x.errno() == EMFILE) ? > + "User limit of inotify instances reached or too many > open files" : > + x.errorString(); > + throw new IOException(msg); > } > > // configure inotify to be non-blocking > diff --git a/src/solaris/native/sun/nio/fs/genUnixConstants.c > b/src/solaris/native/sun/nio/fs/genUnixConstants.c > --- a/src/solaris/native/sun/nio/fs/genUnixConstants.c > +++ b/src/solaris/native/sun/nio/fs/genUnixConstants.c > @@ -108,6 +108,7 @@ int main(int argc, const char* argv[]) { > DEF(EROFS); > DEF(ENODATA); > DEF(ERANGE); > + DEF(EMFILE); > > // flags used with openat/unlinkat/etc. > #if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_REMOVEDIR)