Skip to content

Commit 7b0ad65

Browse files
author
Simon MacMullen
committed
Don't try to read the serevr response using 0-8 semantics. Don't use 0-9-1 semantics either, just report raw values.
1 parent 1440fab commit 7b0ad65

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

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

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,31 @@ public static void protocolVersionMismatch(DataInputStream is) throws IOExceptio
173173
}
174174

175175
try {
176-
int transportHigh = is.readUnsignedByte();
177-
int transportLow = is.readUnsignedByte();
178-
int serverMajor = is.readUnsignedByte();
179-
int serverMinor = is.readUnsignedByte();
180-
181-
// 0-8 gets these the wrong way round
182-
if (serverMajor == 8 && serverMinor == 0) {
183-
serverMajor = 0;
184-
serverMinor = 8;
176+
int[] signature = new int[4];
177+
178+
for (int i = 0; i < 4; i++) {
179+
signature[i] = is.readUnsignedByte();
180+
}
181+
182+
if (signature[0] == 1 &&
183+
signature[1] == 1 &&
184+
signature[2] == 8 &&
185+
signature[3] == 0) {
186+
x = new MalformedFrameException("AMQP protocol version mismatch; we are version " +
187+
AMQP.PROTOCOL.MAJOR + "-" + AMQP.PROTOCOL.MINOR + "-" + AMQP.PROTOCOL.REVISION +
188+
", server is 0-8");
189+
}
190+
else {
191+
String sig = "";
192+
for (int i = 0; i < 4; i++) {
193+
sig += signature[i];
194+
}
195+
196+
x = new MalformedFrameException("AMQP protocol version mismatch; we are version " +
197+
AMQP.PROTOCOL.MAJOR + "-" + AMQP.PROTOCOL.MINOR + "-" + AMQP.PROTOCOL.REVISION +
198+
", server sent signature " + sig);
185199
}
186200

187-
x = new MalformedFrameException("AMQP protocol version mismatch; we are version " + AMQP.PROTOCOL.MAJOR + "-" + AMQP.PROTOCOL.MINOR
188-
+ ", server is " + serverMajor + "-" + serverMinor + " with transport " + transportHigh + "." + transportLow);
189201
} catch (IOException ex) {
190202
x = new MalformedFrameException("Invalid AMQP protocol header from server");
191203
}

0 commit comments

Comments
 (0)