Skip to content

Commit 794241a

Browse files
committed
Revert "Enhance socket connection with configurable timeout"
This reverts commit 40da3f9.
1 parent ac91b59 commit 794241a

File tree

6 files changed

+32
-141
lines changed

6 files changed

+32
-141
lines changed

orbmain/src/main/java/com/sun/corba/ee/impl/misc/ORBUtility.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
package com.sun.corba.ee.impl.misc;
2222

23-
import java.net.Socket;
2423
import java.security.AccessController;
2524
import java.security.PermissionCollection;
2625
import java.security.Policy;
@@ -73,33 +72,24 @@
7372
import com.sun.corba.ee.impl.ior.iiop.JavaSerializationComponent;
7473
import com.sun.corba.ee.impl.javax.rmi.CORBA.Util;
7574

76-
import static com.sun.corba.ee.spi.misc.ORBConstants.TRANSPORT_TCP_CONNECT_MAX_TIME_TO_WAIT;
77-
7875
/**
7976
* Handy class full of static functions that don't belong in util.Utility for pure ORB reasons.
8077
*/
8178
public final class ORBUtility {
82-
83-
public static SocketChannel openSocketChannel(SocketAddress sa) throws IOException {
84-
return openSocketChannel(sa, TRANSPORT_TCP_CONNECT_MAX_TIME_TO_WAIT);
85-
}
86-
8779
/** Utility method for working around leak in SocketChannel.open( SocketAddress )
8880
* method.
8981
* @param sa address to connect to
90-
* @param timeout – the timeout value to be used in milliseconds.
9182
* @return The opened channel
9283
* @throws java.io.IOException If an I/O error occurs
9384
* @see SocketChannel#connect(java.net.SocketAddress)
9485
*/
95-
public static SocketChannel openSocketChannel(SocketAddress sa, int timeout)
86+
public static SocketChannel openSocketChannel( SocketAddress sa )
9687
throws IOException {
9788

9889
SocketChannel sc = SocketChannel.open() ;
9990

10091
try {
101-
Socket socket = sc.socket();
102-
socket.connect(sa, timeout);
92+
sc.connect( sa ) ;
10393
return sc ;
10494
} catch (RuntimeException | IOException exc ) {
10595
try {

orbmain/src/main/java/com/sun/corba/ee/impl/transport/ConnectionImpl.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,8 @@ private ConnectionImpl(ORB orb,
225225
this.contactInfo = contactInfo;
226226

227227
try {
228-
TcpTimeouts tcpConnectTimeouts = orb.getORBData().getTransportTcpConnectTimeouts();
229228
defineSocket(useSelectThreadToWait,
230-
orb.getORBData().getSocketFactory().createSocket(
231-
orb.getORBData().connectionSocketType(),
232-
new InetSocketAddress(hostname, port),
233-
tcpConnectTimeouts.get_max_time_to_wait())
234-
);
229+
orb.getORBData().getSocketFactory().createSocket(socketType, new InetSocketAddress(hostname, port)));
235230
} catch (Throwable t) {
236231
throw wrapper.connectFailure(t, socketType, hostname,
237232
Integer.toString(port));

orbmain/src/main/java/com/sun/corba/ee/impl/transport/DefaultSocketFactoryImpl.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
public class DefaultSocketFactoryImpl
3939
implements ORBSocketFactory
4040
{
41-
protected ORB orb;
41+
private ORB orb;
4242

4343
public void setORB(ORB orb)
4444
{
@@ -62,6 +62,27 @@ public ServerSocket createServerSocket(String type,
6262
return serverSocket;
6363
}
6464

65+
public Socket createSocket(String type,
66+
InetSocketAddress inetSocketAddress)
67+
throws IOException
68+
{
69+
SocketChannel socketChannel = null;
70+
Socket socket = null;
71+
72+
if (orb.getORBData().connectionSocketType().equals(ORBConstants.SOCKETCHANNEL)) {
73+
socketChannel = ORBUtility.openSocketChannel(inetSocketAddress);
74+
socket = socketChannel.socket();
75+
} else {
76+
socket = new Socket(inetSocketAddress.getHostName(),
77+
inetSocketAddress.getPort());
78+
}
79+
80+
// Disable Nagle's algorithm (i.e., always send immediately).
81+
socket.setTcpNoDelay(true);
82+
83+
return socket;
84+
}
85+
6586
public void setAcceptedSocketOptions(Acceptor acceptor,
6687
ServerSocket serverSocket,
6788
Socket socket)

orbmain/src/main/java/com/sun/corba/ee/spi/transport/ORBSocketFactory.java

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,9 @@
2424
import java.net.Socket;
2525
import java.net.SocketException;
2626
import java.net.ServerSocket;
27-
import java.nio.channels.SocketChannel;
2827

29-
import com.sun.corba.ee.impl.misc.ORBUtility;
30-
import com.sun.corba.ee.spi.misc.ORBConstants;
3128
import com.sun.corba.ee.spi.orb.ORB;
3229

33-
import static com.sun.corba.ee.spi.misc.ORBConstants.TRANSPORT_TCP_CONNECT_MAX_TIME_TO_WAIT;
34-
3530
/**
3631
* @author Harold Carr
3732
*/
@@ -43,31 +38,9 @@ public ServerSocket createServerSocket(String type,
4338
InetSocketAddress inetSocketAddress)
4439
throws IOException;
4540

46-
public default Socket createSocket(String type,
47-
InetSocketAddress inetSocketAddress) throws IOException {
48-
return createSocket(type, inetSocketAddress, TRANSPORT_TCP_CONNECT_MAX_TIME_TO_WAIT);
49-
}
50-
51-
public default Socket createSocket(String type,
52-
InetSocketAddress inetSocketAddress,
53-
int timeout)
54-
throws IOException {
55-
SocketChannel socketChannel = null;
56-
Socket socket = null;
57-
58-
if (type.equals(ORBConstants.SOCKETCHANNEL)) {
59-
socketChannel = ORBUtility.openSocketChannel(inetSocketAddress, timeout);
60-
socket = socketChannel.socket();
61-
} else {
62-
socket = new Socket();
63-
socket.connect(inetSocketAddress, timeout);
64-
}
65-
66-
// Disable Nagle's algorithm (i.e., always send immediately).
67-
socket.setTcpNoDelay(true);
68-
69-
return socket;
70-
}
41+
public Socket createSocket(String type,
42+
InetSocketAddress inetSocketAddress)
43+
throws IOException;
7144

7245
public void setAcceptedSocketOptions(Acceptor acceptor,
7346
ServerSocket serverSocket,

orbmain/src/test/java/com/sun/corba/ee/impl/transport/DefaultSocketFactoryImplTest.java

Lines changed: 0 additions & 85 deletions
This file was deleted.

test/src/share/classes/corba/nortel/NortelSocketFactory.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package corba.nortel ;
2121

2222
import com.sun.corba.ee.impl.transport.DefaultSocketFactoryImpl;
23-
import com.sun.corba.ee.spi.transport.TcpTimeouts;
2423

2524
import java.io.IOException;
2625

@@ -63,15 +62,13 @@ public Socket createSocket(String type, InetSocketAddress in) throws IOException
6362
}
6463

6564
Socket socket = null;
66-
TcpTimeouts tcpConnectTimeouts = orb.getORBData().getTransportTcpConnectTimeouts();
6765
if (useNio) {
68-
socket = super.createSocket(orb.getORBData().connectionSocketType(), in, tcpConnectTimeouts.get_max_time_to_wait());
66+
socket = super.createSocket(type, in);
6967
} else {
70-
socket = new Socket();
71-
socket.connect(in, tcpConnectTimeouts.get_max_time_to_wait());
68+
socket = new Socket(in.getHostName(), in.getPort());
69+
socket.setTcpNoDelay(true);
7270
}
73-
74-
socket.setTcpNoDelay(true);
71+
7572
savedSocket = socket;
7673
return socket;
7774
}

0 commit comments

Comments
 (0)