CloseThenRegister.java revision 673
673N/A/*
673N/A * Copyright 2008 Sun Microsystems, Inc. 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 *
673N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
673N/A * CA 95054 USA or visit www.sun.com if you need additional information or
673N/A * have any 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 {
673N/A try {
673N/A Selector s = Selector.open();
673N/A s.close();
673N/A ServerSocketChannel c = ServerSocketChannel.open();
673N/A c.socket().bind(new InetSocketAddress(40000));
673N/A c.configureBlocking(false);
673N/A c.register(s, SelectionKey.OP_ACCEPT);
673N/A } catch (ClosedSelectorException cse) {
673N/A return;
673N/A }
673N/A throw new RuntimeException("register after close does not cause CSE!");
673N/A }
673N/A
673N/A}