test/java/rmi/server/RemoteServer/AddrInUse.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1998, 2003, 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) 1998, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 24,44 **** /* @test * @bug 4111507 * @summary retryServerSocket should not retry on BindException * @author Ann Wollrath * * @build AddrInUse * @run main/othervm AddrInUse */ import java.net.ServerSocket; import java.rmi.registry.LocateRegistry; import java.rmi.server.ExportException; public class AddrInUse implements Runnable { ! private static final int PORT = 9999; private static final long TIMEOUT = 10000; private boolean exportSucceeded = false; private Throwable exportException = null; --- 24,45 ---- /* @test * @bug 4111507 * @summary retryServerSocket should not retry on BindException * @author Ann Wollrath * + * @library ../../testlibrary * @build AddrInUse * @run main/othervm AddrInUse */ import java.net.ServerSocket; import java.rmi.registry.LocateRegistry; import java.rmi.server.ExportException; public class AddrInUse implements Runnable { ! private static int port = -1; private static final long TIMEOUT = 10000; private boolean exportSucceeded = false; private Throwable exportException = null;
*** 47,57 **** /* * Attempt to create (i.e. export) a registry on the port that * has already been bound, and record the result. */ try { ! LocateRegistry.createRegistry(PORT); synchronized (this) { exportSucceeded = true; notifyAll(); } } catch (Throwable t) { --- 48,58 ---- /* * Attempt to create (i.e. export) a registry on the port that * has already been bound, and record the result. */ try { ! LocateRegistry.createRegistry(port); synchronized (this) { exportSucceeded = true; notifyAll(); } } catch (Throwable t) {
*** 66,77 **** System.err.println("\nRegression test for bug 4111507\n"); /* * Bind a server socket to a port. */ ! System.err.println("create a ServerSocket on port " + PORT + "..."); ! ServerSocket server = new ServerSocket(PORT); /* * Start a thread that creates a registry on the same port, * and analyze the result. */ --- 67,79 ---- System.err.println("\nRegression test for bug 4111507\n"); /* * Bind a server socket to a port. */ ! ServerSocket server = new ServerSocket(0); ! port = server.getLocalPort(); ! System.err.println("Created a ServerSocket on port " + port + "..."); /* * Start a thread that creates a registry on the same port, * and analyze the result. */