Skip to content

Commit ee1e897

Browse files
committed
Use Package#getImplementationVersion to get version
The previous method (property file in the JAR) can cause problem in classpath-sensitive environments like OSGi. Fixes #334
1 parent ded8e38 commit ee1e897

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

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

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,12 @@
1515

1616
package com.rabbitmq.client.impl;
1717

18-
import java.io.IOException;
19-
import java.io.InputStream;
20-
import java.util.Properties;
21-
2218
/**
2319
* Publicly available Client Version information
2420
*/
2521
public class ClientVersion {
2622
/** Full version string */
27-
private static final Properties version;
28-
public static final String VERSION;
29-
30-
static {
31-
version = new Properties();
32-
InputStream inputStream = ClientVersion.class.getClassLoader()
33-
.getResourceAsStream("version.properties");
34-
try {
35-
version.load(inputStream);
36-
} catch (IOException e) {
37-
} finally {
38-
try {
39-
if(inputStream != null) {
40-
inputStream.close();
41-
}
42-
} catch (IOException e) {
43-
}
44-
}
23+
public static final String VERSION = ClientVersion.class.getPackage().getImplementationVersion() == null ?
24+
"0.0.0" : ClientVersion.class.getPackage().getImplementationVersion();
4525

46-
VERSION = version.getProperty("com.rabbitmq.client.version",
47-
ClientVersion.class.getPackage().getImplementationVersion());
48-
}
4926
}

0 commit comments

Comments
 (0)