|
184 | 184 | */ |
185 | 185 | public class ArcusClient extends FrontCacheMemcachedClient implements ArcusClientIF { |
186 | 186 |
|
187 | | - private static String VERSION; |
| 187 | + private static String VERSION = "INIT"; |
188 | 188 | private static final Logger arcusLogger = LoggerFactory.getLogger(ArcusClient.class); |
189 | 189 | private static final String ARCUS_CLOUD_ADDR = "127.0.0.1:2181"; |
190 | 190 | private static final String DEFAULT_ARCUS_CLIENT_NAME = "ArcusClient"; |
@@ -4624,30 +4624,37 @@ public void complete() { |
4624 | 4624 | * @return version string |
4625 | 4625 | */ |
4626 | 4626 | public static String getVersion() { |
4627 | | - if (VERSION == null) { |
4628 | | - VERSION = "NONE"; |
4629 | | - |
4630 | | - Enumeration<URL> resEnum; |
4631 | | - try { |
4632 | | - resEnum = Thread.currentThread() |
4633 | | - .getContextClassLoader().getResources(JarFile.MANIFEST_NAME); |
4634 | | - while (resEnum.hasMoreElements()) { |
4635 | | - URL url = resEnum.nextElement(); |
4636 | | - InputStream is = url.openStream(); |
4637 | | - if (is != null) { |
4638 | | - Manifest manifest = new Manifest(is); |
4639 | | - java.util.jar.Attributes mainAttribs = manifest.getMainAttributes(); |
4640 | | - String version = mainAttribs.getValue("Arcusclient-Version"); |
4641 | | - if (version != null) { |
4642 | | - VERSION = version; |
| 4627 | + if (!VERSION.equals("INIT")) { |
| 4628 | + return VERSION; |
| 4629 | + } |
| 4630 | + synchronized (VERSION) { |
| 4631 | + if (VERSION.equals("INIT")) { |
| 4632 | + Enumeration<URL> resEnum; |
| 4633 | + try { |
| 4634 | + resEnum = Thread.currentThread() |
| 4635 | + .getContextClassLoader().getResources(JarFile.MANIFEST_NAME); |
| 4636 | + while (resEnum.hasMoreElements()) { |
| 4637 | + URL url = resEnum.nextElement(); |
| 4638 | + InputStream is = url.openStream(); |
| 4639 | + if (is != null) { |
| 4640 | + Manifest manifest = new Manifest(is); |
| 4641 | + java.util.jar.Attributes mainAttribs = manifest.getMainAttributes(); |
| 4642 | + String version = mainAttribs.getValue("Arcusclient-Version"); |
| 4643 | + if (version != null) { |
| 4644 | + VERSION = version; |
| 4645 | + break; |
| 4646 | + } |
4643 | 4647 | } |
4644 | 4648 | } |
| 4649 | + } catch (Exception e) { |
| 4650 | + // Failed to get version. |
| 4651 | + } finally { |
| 4652 | + if (VERSION.equals("INIT")) { |
| 4653 | + VERSION = "NONE"; |
| 4654 | + } |
4645 | 4655 | } |
4646 | | - } catch (Exception e) { |
4647 | | - // Failed to get version. |
4648 | 4656 | } |
4649 | 4657 | } |
4650 | | - |
4651 | 4658 | return VERSION; |
4652 | 4659 | } |
4653 | 4660 | } |
0 commit comments