|
17 | 17 |
|
18 | 18 | import com.rabbitmq.client.Connection; |
19 | 19 | import com.rabbitmq.client.ConnectionFactory; |
| 20 | +import org.slf4j.LoggerFactory; |
20 | 21 |
|
21 | 22 | import java.io.IOException; |
22 | 23 |
|
@@ -45,20 +46,27 @@ public static void close(Connection connection) { |
45 | 46 | } |
46 | 47 |
|
47 | 48 | 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; |
60 | 68 | } |
61 | | - return "0.0.0".equals(currentVersion) || versionCompare(currentVersion, "3.7.0") >= 0; |
| 69 | + |
62 | 70 | } |
63 | 71 |
|
64 | 72 | /** |
|
0 commit comments