You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by mi...@apache.org on 2015/02/11 10:53:55 UTC
svn commit: r1658910 -
/httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/VersionInfo.java
Author: michaelo
Date: Wed Feb 11 09:53:55 2015
New Revision: 1658910
URL: http://svn.apache.org/r1658910
Log:
HTTPCORE-395: VersionInfo#getUserAgent reports incorrect Java version
Modified:
httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/VersionInfo.java
Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/VersionInfo.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/VersionInfo.java?rev=1658910&r1=1658909&r2=1658910&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/VersionInfo.java (original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/VersionInfo.java Wed Feb 11 09:53:55 2015
@@ -301,10 +301,11 @@ public class VersionInfo {
}
/**
- * Sets the user agent to {@code "<name>/<release> (Java 1.5 minimum; Java/<java.version>)"}.
+ * Sets the user agent to {@code "<name>/<release> (Java/<java.version>)"}. If release is
+ * {@link #UNAVAILABLE}, it will be omitted.
* <p>
* For example:
- * <pre>"Apache-HttpClient/4.3 (Java 1.5 minimum; Java/1.6.0_35)"</pre>
+ * <pre>"Apache-HttpClient/4.3 (Java/1.6.0_35)"</pre>
*
* @param name the component name, like "Apache-HttpClient".
* @param pkg
@@ -319,7 +320,12 @@ public class VersionInfo {
final VersionInfo vi = VersionInfo.loadVersionInfo(pkg, cls.getClassLoader());
final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE;
final String javaVersion = System.getProperty("java.version");
- return name + "/" + release + " (Java 1.5 minimum; Java/" + javaVersion + ")";
+
+ String nameAndRelease = name;
+ if (!UNAVAILABLE.equals(release))
+ nameAndRelease += "/" + release;
+
+ return String.format("%s (Java/%s)", nameAndRelease, javaVersion);
}
} // class VersionInfo