--- old/test/java/nio/channels/SocketChannel/IsConnectable.java 2012-10-30 18:40:32.000000000 +0100 +++ new/test/java/nio/channels/SocketChannel/IsConnectable.java 2012-10-30 18:40:32.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,24 +28,18 @@ */ import java.net.*; -import java.io.*; -import java.nio.*; import java.nio.channels.*; import java.nio.channels.spi.SelectorProvider; import java.util.*; public class IsConnectable { - static final int DAYTIME_PORT = 13; - static final String DAYTIME_HOST = TestUtil.HOST; - - static void test() throws Exception { - InetSocketAddress isa - = new InetSocketAddress(InetAddress.getByName(DAYTIME_HOST), - DAYTIME_PORT); + static void test(TestUtil.DayTimeServer daytimeServer) throws Exception { + InetSocketAddress isa = new InetSocketAddress(daytimeServer.getAddress(), + daytimeServer.getPort()); SocketChannel sc = SocketChannel.open(); sc.configureBlocking(false); - sc.connect(isa); + final boolean immediatelyConnected = sc.connect(isa); Selector selector = SelectorProvider.provider().openSelector(); try { @@ -67,7 +61,12 @@ throw new Exception("Test failed: 4737146 detected"); } } else { - throw new Exception("Select failed"); + if (!immediatelyConnected) { + throw new Exception("Select failed"); + } else { + System.err.println("IsConnectable couldn't be tested for " + + System.getProperty("os.name")); + } } } finally { sc.close(); @@ -76,7 +75,10 @@ } public static void main(String[] args) throws Exception { - test(); + try (TestUtil.DayTimeServer daytimeServer = + TestUtil.DayTimeServer.startNewServer(100)) { + test(daytimeServer); + } } }