< prev index next >

test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/CloseTest.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 2017, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2003, 2018, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 36,45 **** --- 36,47 ---- import java.nio.ByteBuffer; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.SocketChannel; + import jdk.test.lib.Utils; + public class CloseTest { public static void main(String args[]) throws Exception { String msg = "HELLO";
*** 48,58 **** // closing the connection the service should hang around // for 15 seconds. String service_args[] = new String[2]; service_args[0] = String.valueOf(msg.length()); ! service_args[1] = String.valueOf( 15*1000 ); SocketChannel sc = Launcher.launchWithSocketChannel("EchoService", service_args); // send message - service will echo the message and close the connection. --- 50,60 ---- // closing the connection the service should hang around // for 15 seconds. String service_args[] = new String[2]; service_args[0] = String.valueOf(msg.length()); ! service_args[1] = String.valueOf( Utils.adjustTimeout(15*1000) ); SocketChannel sc = Launcher.launchWithSocketChannel("EchoService", service_args); // send message - service will echo the message and close the connection.
*** 63,73 **** ByteBuffer bb = ByteBuffer.allocateDirect(50); sc.configureBlocking(false); Selector sel = sc.provider().openSelector(); SelectionKey sk = sc.register(sel, SelectionKey.OP_READ); ! long to = 12 * 1000; for (;;) { long st = System.currentTimeMillis(); sel.select(to); if (sk.isReadable()) { int n = sc.read(bb); --- 65,75 ---- ByteBuffer bb = ByteBuffer.allocateDirect(50); sc.configureBlocking(false); Selector sel = sc.provider().openSelector(); SelectionKey sk = sc.register(sel, SelectionKey.OP_READ); ! long to = Utils.adjustTimeout(12*1000); for (;;) { long st = System.currentTimeMillis(); sel.select(to); if (sk.isReadable()) { int n = sc.read(bb);
< prev index next >