commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: Porting URIBuilder call sites
Date Fri, 13 Jul 2018 19:03:33 GMT
On Fri, Jul 13, 2018 at 12:38 PM Pascal Schumacher <pascalschumacher@gmx.net>
wrote:

> I guess this was send to the wrong mailing list?
>

Yep, sorry.

Gary

>
> Am 12.07.2018 um 17:22 schrieb Gary Gregory:
> > Hi All,
> >
> > I just had to port this 'nice' fluent code:
> >
> >              final String uri = new URIBuilder()
> >                  .setScheme(scheme)
> >                  .setHost("localhost")
> >                  .setUserInfo(userInfo)
> >                  .setPort(proxyPort)
> >                  .setPath(path)
> >                  .setCustomQuery(queryParameterString)
> >                  .build()
> >                  .toString();
> >
> > to:
> >
> >              final URIBuilder builder = new URIBuilder()
> >                  .setScheme(scheme)
> >                  .setHost("localhost")
> >                  .setPort(proxyPort)
> >                  .setPath(path)
> >                  .setCustomQuery(queryParameterString);
> >              if (StringUtils.isNotBlank(userInfo)) {
> >                  builder.setUserInfo(userInfo);
> >              }
> >              final String uri = builder.build().toString();
> >
> > To avoid an IllegalArgumentException when userInfo is "":
> >
> > java.lang.IllegalArgumentException: User info may not be empty
> > at org.apache.hc.core5.util.Args.containsNoBlanks(Args.java:84)
> > at org.apache.hc.core5.net.URIAuthority.<init>(URIAuthority.java:73)
> > at
> >
> org.apache.hc.core5.http.message.BasicHttpRequest.setUri(BasicHttpRequest.java:172)
> > at
> >
> org.apache.hc.core5.http.message.BasicHttpRequest.<init>(BasicHttpRequest.java:102)
> > at
> >
> org.apache.hc.core5.http.message.BasicClassicHttpRequest.<init>(BasicClassicHttpRequest.java:77)
> > at
> >
> org.apache.hc.client5.http.classic.methods.HttpUriRequestBase.<init>(HttpUriRequestBase.java:48)
> > at
> >
> org.apache.hc.client5.http.classic.methods.RequestBuilder.build(RequestBuilder.java:482)
> > at
> >
> com.rs.seagull.httpmonitor.ClientTests.testHttpMethod(ClientTests.java:106)
> > ...
> >
> > I would be nice to still offer this fluent style when userInfo is null
> (and
> > even "")
> >
> > Thoughts?
> >
> > Gary
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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