Skip to content

Commit

Permalink
Fix warnings in ClientVersion when amqp-client is relocated
Browse files Browse the repository at this point in the history
(cherry picked from commit 3f25e9f)
  • Loading branch information
astei authored and acogoluegnes committed Jan 2, 2019
1 parent 1eb5590 commit f2470e0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/com/rabbitmq/client/impl/ClientVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public class ClientVersion {

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

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

public static final String VERSION;

static {
Expand Down Expand Up @@ -56,10 +61,12 @@ private static final String getVersionFromPropertyFile() throws Exception {
inputStream.close();
}
}
if (version.getProperty("com.rabbitmq.client.version") == null) {
throw new IllegalStateException("Coulnd't find version property in property file");
String propertyName = new String(VERSION_PROPERTY);
String versionProperty = version.getProperty(propertyName);
if (versionProperty == null) {
throw new IllegalStateException("Couldn't find version property in property file");
}
return version.getProperty("com.rabbitmq.client.version");
return versionProperty;
}

private static final String getVersionFromPackage() {
Expand Down

0 comments on commit f2470e0

Please sign in to comment.