Skip to content

Commit 0aa2205

Browse files
author
Emile Joubert
committed
Add missing file from bug24747
1 parent fef6bd4 commit 0aa2205

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/com/rabbitmq/client/impl/AMQConnection.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.IOException;
2121
import java.net.InetAddress;
2222
import java.net.SocketException;
23+
import java.net.SocketTimeoutException;
2324
import java.util.Collections;
2425
import java.util.HashMap;
2526
import java.util.Map;
@@ -108,6 +109,9 @@ public static final Map<String, Object> defaultClientProperties() {
108109
/** Flag indicating whether the client received Connection.Close message from the broker */
109110
private volatile boolean _brokerInitiatedShutdown;
110111

112+
/** Flag indicating we are still negotiating the connection in start */
113+
private volatile boolean _inConnectionNegotiation;
114+
111115
/** Manages heart-beat sending for this connection */
112116
private final HeartbeatSender _heartbeatSender;
113117

@@ -248,6 +252,8 @@ public AMQConnection(String username,
248252

249253
this._heartbeatSender = new HeartbeatSender(frameHandler);
250254
this._brokerInitiatedShutdown = false;
255+
256+
this._inConnectionNegotiation = true; // we start out waiting for the first protocol response
251257
}
252258

253259
/**
@@ -385,6 +391,9 @@ public void start()
385391
throw AMQChannel.wrap(sse);
386392
}
387393

394+
// We can now respond to errors having finished tailoring the connection
395+
this._inConnectionNegotiation = false;
396+
388397
return;
389398
}
390399

@@ -538,7 +547,11 @@ private class MainLoop extends Thread {
538547
* Called when a frame-read operation times out
539548
* @throws MissedHeartbeatException if heart-beats have been missed
540549
*/
541-
private void handleSocketTimeout() throws MissedHeartbeatException {
550+
private void handleSocketTimeout() throws SocketTimeoutException {
551+
if (_inConnectionNegotiation) {
552+
throw new SocketTimeoutException("Timeout during Connection negotiation");
553+
}
554+
542555
if (_heartbeat == 0) { // No heart-beating
543556
return;
544557
}

0 commit comments

Comments
 (0)