673N/A/*
3261N/A * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
673N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
673N/A *
673N/A * This code is free software; you can redistribute it and/or modify it
673N/A * under the terms of the GNU General Public License version 2 only, as
673N/A * published by the Free Software Foundation.
673N/A *
673N/A * This code is distributed in the hope that it will be useful, but WITHOUT
673N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
673N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
673N/A * version 2 for more details (a copy is included in the LICENSE file that
673N/A * accompanied this code).
673N/A *
673N/A * You should have received a copy of the GNU General Public License version
673N/A * 2 along with this work; if not, write to the Free Software Foundation,
673N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
673N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
673N/A */
673N/A
673N/A/* @test
673N/A * @bug 5025260
673N/A * @summary ClosedSelectorException is expected when register after close
673N/A */
673N/A
673N/Aimport java.net.*;
673N/Aimport java.nio.channels.*;
673N/A
673N/Apublic class CloseThenRegister {
673N/A
673N/A public static void main (String [] args) throws Exception {
2485N/A Selector sel = Selector.open();
2485N/A sel.close();
2485N/A ServerSocketChannel ssc = ServerSocketChannel.open();
673N/A try {
2485N/A ssc.bind(new InetSocketAddress(0));
2485N/A ssc.configureBlocking(false);
2485N/A ssc.register(sel, SelectionKey.OP_ACCEPT);
2485N/A throw new RuntimeException("register after close does not cause CSE!");
673N/A } catch (ClosedSelectorException cse) {
2485N/A // expected
2485N/A } finally {
2485N/A ssc.close();
673N/A }
673N/A }
673N/A
673N/A}