957N/A/*
957N/A * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
957N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
957N/A *
957N/A * This code is free software; you can redistribute it and/or modify it
957N/A * under the terms of the GNU General Public License version 2 only, as
957N/A * published by the Free Software Foundation.
957N/A *
957N/A * This code is distributed in the hope that it will be useful, but WITHOUT
957N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
957N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
957N/A * version 2 for more details (a copy is included in the LICENSE file that
957N/A * accompanied this code).
957N/A *
957N/A * You should have received a copy of the GNU General Public License version
957N/A * 2 along with this work; if not, write to the Free Software Foundation,
957N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
957N/A *
957N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
957N/A * or visit www.oracle.com if you need additional information or have any
957N/A * questions.
957N/A */
957N/A
957N/A/* @test
957N/A * @bug 6548464
957N/A * @summary SocketChannel.open(SocketAddress) leaks file descriptor if
957N/A * connection cannot be established
957N/A * @build OpenLeak
957N/A * @run main/othervm OpenLeak
957N/A */
957N/A
957N/Aimport java.net.InetAddress;
957N/Aimport java.net.InetSocketAddress;
957N/Aimport java.nio.channels.SocketChannel;
957N/A
957N/Apublic class OpenLeak {
957N/A
957N/A public static void main(String[] args) throws Exception {
957N/A InetAddress lh = InetAddress.getLocalHost();
957N/A InetSocketAddress isa = new InetSocketAddress(lh, 12345);
957N/A
957N/A System.setSecurityManager( new SecurityManager() );
957N/A for (int i=0; i<100000; i++) {
try {
SocketChannel.open(isa);
throw new RuntimeException("This should not happen");
} catch (SecurityException x) { }
}
}
}