hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: svn commit: r1411518
Date Tue, 20 Nov 2012 19:24:36 GMT
On Tue, Nov 20, 2012 at 7:48 AM, Gary Gregory <garydgregory@gmail.com>wrote:

> On Nov 20, 2012, at 6:11, Oleg Kalnichevski <olegk@apache.org> wrote:
>
> > On Tue, 2012-11-20 at 02:42 +0000, ggregory@apache.org wrote:
> >> Author: ggregory
> >> Date: Tue Nov 20 02:42:15 2012
> >> New Revision: 1411518
> >>
> >> URL: http://svn.apache.org/viewvc?rev=1411518&view=rev
> >> Log:
> >> Added the method
> org.apache.http.util.VersionInfo.setUserAgent(HttpParams, String, String,
> Class<?>)
> >> TODO This needs adjusting to account for the deprecated types {@link
> HttpParams} and {@link HttpProtocolParams}.
> >>
> >> Modified:
> >>
>  httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/VersionInfo.java
> >>
> >> Modified:
> httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/VersionInfo.java
> >> URL:
> http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/VersionInfo.java?rev=1411518&r1=1411517&r2=1411518&view=diff
> >>
> ==============================================================================
> >> ---
> httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/VersionInfo.java
> (original)
> >> +++
> httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/VersionInfo.java
> Tue Nov 20 02:42:15 2012
> >> @@ -34,6 +34,9 @@ import java.util.List;
> >> import java.util.Map;
> >> import java.util.Properties;
> >>
> >> +import org.apache.http.params.HttpParams;
> >> +import org.apache.http.params.HttpProtocolParams;
> >> +
> >>
> >> /**
> >>  * Provides access to version information for HTTP components.
> >> @@ -292,4 +295,29 @@ public class VersionInfo {
> >>         return new VersionInfo(pckg, module, release, timestamp,
> clsldrstr);
> >>     }
> >>
> >> +    /**
> >> +     * Sets the user agent to {@code "<name>/<release> (Java 1.5
> minimum; Java/<java.version>)"}.
> >> +     * <p/>
> >> +     * For example:
> >> +     * <pre>"Apache-HttpClient/4.3 (Java 1.5 minimum;
> Java/1.6.0_35)"</pre>
> >> +     *
> >> +     * TODO This needs adjusting to account for the deprecated types
> {@link HttpParams} and {@link HttpProtocolParams}.
> >> +     *
> >> +     * @param params
> >> +     *            the HTTP parameters where the user agent will be set
> >> +     * @name the component name, like "Apache-HttpClient".
> >> +     * @param pkg
> >> +     *            the package for which to load version information,
> for example "org.apache.http". The package name
> >> +     *            should NOT end with a dot.
> >> +     * @param cls
> >> +     *            the class' class loader to load from, or
> <code>null</code> for the thread context class loader
> >> +     */
> >> +    public static void setUserAgent(HttpParams params, String name,
> String pkg, Class<?> cls) {
> >> +        // determine the release version from packaged version info
> >> +        final VersionInfo vi = VersionInfo.loadVersionInfo(pkg,
> cls.getClassLoader());
> >> +        final String release = (vi != null) ? vi.getRelease() :
> VersionInfo.UNAVAILABLE;
> >> +        final String javaVersion = System.getProperty("java.version");
> >> +        HttpProtocolParams.setUserAgent(params, name + "/" + release +
> " (Java 1.5 minimum; Java/" + javaVersion + ")");
> >> +    }
> >> +
> >> } // class VersionInfo
> >>
> >>
> >
> > Gary,
> >
> > I think there is no need for this method to depend on HttpParams or any
> > other configuration API. In my opinion it should simply return string.
> >
> > Please note that System#getProperty method can be very treacherous.
> > Depending on the application security context it can throw unchecked
> > SecurityException. #setUserAgent should either catch the exception and
> > gracefully recover or explicitly declare SecurityException as thrown by
> > the method.
>
> Ok, I'll change all that.
>

But SVN commit access is broken for me ATM. I am told this is being
experienced by others and is being addressed...

Gary

>
> Gary
>
> >
> > Oleg
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> > For additional commands, e-mail: dev-help@hc.apache.org
> >
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message