Skip to content

Commit 9ef2cf8

Browse files
asteiacogoluegnes
authored andcommitted
Fix warnings in ClientVersion when amqp-client is relocated
(cherry picked from commit 3f25e9f)
1 parent 2642c7d commit 9ef2cf8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/java/com/rabbitmq/client/impl/ClientVersion.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public class ClientVersion {
2828

2929
private static final Logger LOGGER = LoggerFactory.getLogger(ClientVersion.class);
3030

31+
// We store the version property in an unusual way because relocating the package can rewrite the key in the property
32+
// file, which results in spurious warnings being emitted at start-up.
33+
private static final char[] VERSION_PROPERTY = new char[] {'c', 'o', 'm', '.', 'r', 'a', 'b', 'b', 'i', 't', 'm', 'q', '.',
34+
'c', 'l', 'i', 'e', 'n', 't', '.', 'v', 'e', 'r', 's', 'i', 'o', 'n'};
35+
3136
public static final String VERSION;
3237

3338
static {
@@ -56,10 +61,12 @@ private static final String getVersionFromPropertyFile() throws Exception {
5661
inputStream.close();
5762
}
5863
}
59-
if (version.getProperty("com.rabbitmq.client.version") == null) {
60-
throw new IllegalStateException("Coulnd't find version property in property file");
64+
String propertyName = new String(VERSION_PROPERTY);
65+
String versionProperty = version.getProperty(propertyName);
66+
if (versionProperty == null) {
67+
throw new IllegalStateException("Couldn't find version property in property file");
6168
}
62-
return version.getProperty("com.rabbitmq.client.version");
69+
return versionProperty;
6370
}
6471

6572
private static final String getVersionFromPackage() {

0 commit comments

Comments
 (0)