Skip to content

Commit 2e2dc24

Browse files
committed
Log on broker version parsing error in tests
1 parent 7d6a431 commit 2e2dc24

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/test/java/com/rabbitmq/client/test/TestUtils.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.rabbitmq.client.Connection;
1919
import com.rabbitmq.client.ConnectionFactory;
20+
import org.slf4j.LoggerFactory;
2021

2122
import java.io.IOException;
2223

@@ -45,20 +46,27 @@ public static void close(Connection connection) {
4546
}
4647

4748
public static boolean isVersion37orLater(Connection connection) {
48-
String currentVersion = connection.getServerProperties().get("version").toString();
49-
// versions built from source: 3.7.0+rc.1.4.gedc5d96
50-
if (currentVersion.contains("+")) {
51-
currentVersion = currentVersion.substring(0, currentVersion.indexOf("+"));
52-
}
53-
// alpha (snapshot) versions: 3.7.0~alpha.449-1
54-
if (currentVersion.contains("~")) {
55-
currentVersion = currentVersion.substring(0, currentVersion.indexOf("~"));
56-
}
57-
// alpha (snapshot) versions: 3.7.1-alpha.40
58-
if (currentVersion.contains("-")) {
59-
currentVersion = currentVersion.substring(0, currentVersion.indexOf("-"));
49+
String currentVersion = null;
50+
try {
51+
currentVersion = connection.getServerProperties().get("version").toString();
52+
// versions built from source: 3.7.0+rc.1.4.gedc5d96
53+
if (currentVersion.contains("+")) {
54+
currentVersion = currentVersion.substring(0, currentVersion.indexOf("+"));
55+
}
56+
// alpha (snapshot) versions: 3.7.0~alpha.449-1
57+
if (currentVersion.contains("~")) {
58+
currentVersion = currentVersion.substring(0, currentVersion.indexOf("~"));
59+
}
60+
// alpha (snapshot) versions: 3.7.1-alpha.40
61+
if (currentVersion.contains("-")) {
62+
currentVersion = currentVersion.substring(0, currentVersion.indexOf("-"));
63+
}
64+
return "0.0.0".equals(currentVersion) || versionCompare(currentVersion, "3.7.0") >= 0;
65+
} catch (RuntimeException e) {
66+
LoggerFactory.getLogger(TestUtils.class).warn("Unable to parse broker version {}", currentVersion, e);
67+
throw e;
6068
}
61-
return "0.0.0".equals(currentVersion) || versionCompare(currentVersion, "3.7.0") >= 0;
69+
6270
}
6371

6472
/**

0 commit comments

Comments
 (0)