renatoh commented on code in PR #4606:
URL: https://github.com/apache/solr/pull/4606#discussion_r3520166876
##########
solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java:
##########
@@ -458,25 +458,20 @@ public NamedList<Object> toNamedList() {
* empty.
*/
public String toQueryString() {
- try {
- final String charset = StandardCharsets.UTF_8.name();
- final StringBuilder sb = new StringBuilder(128);
- boolean first = true;
- for (final Iterator<String> it = getParameterNamesIterator();
it.hasNext(); ) {
- final String name = it.next(), nameEnc = URLEncoder.encode(name,
charset);
- for (String val : getParams(name)) {
- sb.append(first ? '?' : '&')
- .append(nameEnc)
- .append('=')
- .append(URLEncoder.encode(val, charset));
- first = false;
- }
+ final Charset charset = StandardCharsets.UTF_8;
+ final StringBuilder sb = new StringBuilder(128);
Review Comment:
I am aware this code was not added in this PR, but using a StringJoiner
would eliminate the need for boolean first = true
final StringJoiner sj = new StringJoiner("&", "?", "");
sj.setEmptyValue("");
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]