equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
61 Registry registry = LocateRegistry.createRegistry(PORT); |
61 Registry registry = LocateRegistry.createRegistry(PORT); |
62 System.err.println("- exported registry: " + registry); |
62 System.err.println("- exported registry: " + registry); |
63 verifyPortInUse(PORT); |
63 verifyPortInUse(PORT); |
64 UnicastRemoteObject.unexportObject(registry, true); |
64 UnicastRemoteObject.unexportObject(registry, true); |
65 System.err.println("- unexported registry"); |
65 System.err.println("- unexported registry"); |
66 Thread.sleep(1000); // work around BindException (bug?) |
66 int tries = (int)TestLibrary.getTimeoutFactor(); |
67 verifyPortFree(PORT); |
67 tries = Math.max(tries, 1); |
|
68 while (tries-- > 0) { |
|
69 Thread.sleep(1000); |
|
70 try { |
|
71 verifyPortFree(PORT); |
|
72 break; |
|
73 } catch (IOException ignore) { } |
|
74 } |
|
75 if (tries < 0) { |
|
76 throw new RuntimeException("time out after tries: " + tries); |
|
77 } |
|
78 |
68 |
79 |
69 /* |
80 /* |
70 * The follow portion of this test is disabled temporarily |
81 * The follow portion of this test is disabled temporarily |
71 * because 4457683 was partially backed out because of |
82 * because 4457683 was partially backed out because of |
72 * 6269166; for now, only server sockets originally opened for |
83 * 6269166; for now, only server sockets originally opened for |
99 } |
110 } |
100 |
111 |
101 private static void verifyPortInUse(int port) throws IOException { |
112 private static void verifyPortInUse(int port) throws IOException { |
102 try { |
113 try { |
103 verifyPortFree(port); |
114 verifyPortFree(port); |
|
115 throw new RuntimeException("port is not in use: " + port); |
104 } catch (BindException e) { |
116 } catch (BindException e) { |
105 System.err.println("- port " + port + " is in use"); |
117 System.err.println("- port " + port + " is in use"); |
106 return; |
118 return; |
107 } |
119 } |
108 } |
120 } |