diff --git a/httpcore/pom.xml b/httpcore/pom.xml
index 1c9c5be..0a828bc 100644
--- a/httpcore/pom.xml
+++ b/httpcore/pom.xml
@@ -30,7 +30,7 @@
org.apache.httpcomponents
httpcomponents-core
- 4.3
+ 4.3.mt
httpcore
Apache HttpCore
diff --git a/httpcore/src/main/java/org/apache/http/util/VersionInfo.java b/httpcore/src/main/java/org/apache/http/util/VersionInfo.java
index e870dbc..c0028fa 100644
--- a/httpcore/src/main/java/org/apache/http/util/VersionInfo.java
+++ b/httpcore/src/main/java/org/apache/http/util/VersionInfo.java
@@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
/**
* Provides access to version information for HTTP components.
@@ -75,6 +76,9 @@ public class VersionInfo {
/** The classloader from which the version info was obtained. */
private final String infoClassloader;
+ /** Cache the version info. */
+ private final static ConcurrentHashMap versionInfo = new ConcurrentHashMap();
+
/**
* Instantiates version information.
@@ -223,33 +227,43 @@ public class VersionInfo {
public static VersionInfo loadVersionInfo(final String pckg,
final ClassLoader clsldr) {
Args.notNull(pckg, "Package identifier");
- final ClassLoader cl = clsldr != null ? clsldr : Thread.currentThread().getContextClassLoader();
-
- Properties vip = null; // version info properties, if available
- try {
- // org.apache.http becomes
- // org/apache/http/version.properties
- final InputStream is = cl.getResourceAsStream
- (pckg.replace('.', '/') + "/" + VERSION_PROPERTY_FILE);
- if (is != null) {
- try {
- final Properties props = new Properties();
- props.load(is);
- vip = props;
- } finally {
- is.close();
+ if (versionInfo.get(pckg) == null) {
+ synchronized (versionInfo) {
+ if (versionInfo.get(pckg) == null) {
+ final ClassLoader cl = clsldr != null ? clsldr : Thread.currentThread().getContextClassLoader();
+
+ Properties vip = null; // version info properties, if available
+ try {
+ // org.apache.http becomes
+ // org/apache/http/version.properties
+ final InputStream is = cl.getResourceAsStream
+ (pckg.replace('.', '/') + "/" + VERSION_PROPERTY_FILE);
+ if (is != null) {
+ try {
+ final Properties props = new Properties();
+ props.load(is);
+ vip = props;
+ } finally {
+ is.close();
+ }
+ }
+ } catch (final IOException ex) {
+ // shamelessly munch this exception
+ }
+
+ VersionInfo result = null;
+ if (vip != null) {
+ result = fromMap(pckg, vip, cl);
+ }
+ versionInfo.put(pckg, result);
+ return result;
+ } else {
+ return versionInfo.get(pckg);
}
}
- } catch (final IOException ex) {
- // shamelessly munch this exception
- }
-
- VersionInfo result = null;
- if (vip != null) {
- result = fromMap(pckg, vip, cl);
+ } else {
+ return versionInfo.get(pckg);
}
-
- return result;
}
diff --git a/pom.xml b/pom.xml
index 5885a04..7a00a76 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,7 +34,7 @@
4.0.0
httpcomponents-core
Apache HttpComponents Core
- 4.3
+ 4.3.mt
Core components to build HTTP enabled services
http://hc.apache.org/httpcomponents-core
2005