Skip to content

Commit 388858a

Browse files
authored
Merge pull request #1512 from jglick/connectTcp
Treat `connectTcp` as part of retryable I/O
2 parents 17afb4b + fbb125e commit 388858a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/main/java/hudson/remoting/Engine.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ private void innerRun(IOHub hub, SSLContext context, ExecutorService service) {
10391039
agentTrustManager.setDelegate(delegate);
10401040

10411041
events.status("Handshaking");
1042-
Socket jnlpSocket = connectTcp(endpoint);
1042+
Socket jnlpSocket = null;
10431043
Channel channel = null;
10441044

10451045
try {
@@ -1050,16 +1050,14 @@ private void innerRun(IOHub hub, SSLContext context, ExecutorService service) {
10501050
events.status("Protocol " + protocol.getName() + " is not enabled, skipping");
10511051
continue;
10521052
}
1053-
if (jnlpSocket == null) {
1054-
jnlpSocket = connectTcp(endpoint);
1055-
}
10561053
if (!endpoint.isProtocolSupported(protocol.getName())) {
10571054
events.status("Server reports protocol " + protocol.getName() + " not supported, skipping");
10581055
continue;
10591056
}
10601057
triedAtLeastOneProtocol = true;
10611058
events.status("Trying protocol: " + protocol.getName());
10621059
try {
1060+
jnlpSocket = connectTcp(endpoint);
10631061
channel = protocol.connect(
10641062
jnlpSocket,
10651063
headers,
@@ -1083,8 +1081,14 @@ private void innerRun(IOHub hub, SSLContext context, ExecutorService service) {
10831081
}
10841082

10851083
// On failure form a new connection.
1086-
jnlpSocket.close();
1087-
jnlpSocket = null;
1084+
if (jnlpSocket != null) {
1085+
try {
1086+
jnlpSocket.close();
1087+
} catch (IOException e) {
1088+
events.status("Failed to close socket", e);
1089+
}
1090+
jnlpSocket = null;
1091+
}
10881092
}
10891093

10901094
// If no protocol worked.

0 commit comments

Comments
 (0)