Skip to content

Commit 9b584fa

Browse files
committed
SOLR-17776: Undo unintended internal edits
These were minor internal organizational changes
1 parent dd89cd6 commit 9b584fa

1 file changed

Lines changed: 17 additions & 28 deletions

File tree

solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,15 @@ private void setupProxy(Builder builder, HttpClient httpClient) {
334334
if (builder.proxyIsSocks4) {
335335
proxy = new Socks4Proxy(address, builder.proxyIsSecure);
336336
} else {
337-
// Move protocol initialization closer to where it's used
338-
proxy =
339-
new HttpProxy(
340-
address,
341-
builder.proxyIsSecure,
342-
builder.useHttp1_1
343-
? HttpClientTransportOverHTTP.HTTP11
344-
: new Protocol(List.of(builder.proxyIsSecure ? "h2" : "h2c"), false));
337+
final Protocol protocol;
338+
if (builder.useHttp1_1) {
339+
protocol = HttpClientTransportOverHTTP.HTTP11;
340+
} else {
341+
// see HttpClientTransportOverHTTP2#newOrigin
342+
String protocolName = builder.proxyIsSecure ? "h2" : "h2c";
343+
protocol = new Protocol(List.of(protocolName), false);
344+
}
345+
proxy = new HttpProxy(address, builder.proxyIsSecure, protocol);
345346
}
346347
httpClient.getProxyConfiguration().addProxy(proxy);
347348
}
@@ -644,17 +645,14 @@ private NamedList<Object> processErrorsAndResponse(
644645
solrRequest.getResponseParser() == null ? this.parser : solrRequest.getResponseParser();
645646
String contentType = response.getHeaders().get(HttpHeader.CONTENT_TYPE);
646647

647-
// Move variable initializations closer to where they are used
648-
String responseMethod = response.getRequest() == null ? "" : response.getRequest().getMethod();
649-
650-
// Initialize mimeType and encoding only when needed
651648
String mimeType = null;
652649
String encoding = null;
653650
if (contentType != null) {
654651
mimeType = MimeTypes.getContentTypeWithoutCharset(contentType);
655652
encoding = MimeTypes.getCharsetFromContentType(contentType);
656653
}
657654

655+
String responseMethod = response.getRequest() == null ? "" : response.getRequest().getMethod();
658656
return processErrorsAndResponse(
659657
response.getStatus(),
660658
response.getReason(),
@@ -747,26 +745,22 @@ private MakeRequestReturnValue makeRequest(
747745

748746
if (SolrRequest.METHOD.POST == solrRequest.getMethod()
749747
|| SolrRequest.METHOD.PUT == solrRequest.getMethod()) {
750-
// Move method initialization closer to where it's used
748+
RequestWriter.ContentWriter contentWriter = requestWriter.getContentWriter(solrRequest);
749+
Collection<ContentStream> streams =
750+
contentWriter == null ? requestWriter.getContentStreams(solrRequest) : null;
751+
752+
boolean isMultipart = isMultipart(streams);
753+
751754
HttpMethod method =
752755
SolrRequest.METHOD.POST == solrRequest.getMethod() ? HttpMethod.POST : HttpMethod.PUT;
753756

754-
RequestWriter.ContentWriter contentWriter = requestWriter.getContentWriter(solrRequest);
755-
756757
if (contentWriter != null) {
757758
var content = new OutputStreamRequestContent(contentWriter.getContentType());
758759
var r = httpClient.newRequest(url + wparams.toQueryString()).method(method).body(content);
759760
decorateRequest(r, solrRequest, isAsync);
760761
return new MakeRequestReturnValue(r, contentWriter, content);
761-
}
762-
763-
// Only get streams if contentWriter is null
764-
Collection<ContentStream> streams = requestWriter.getContentStreams(solrRequest);
765762

766-
// Move isMultipart initialization closer to where it's used
767-
boolean isMultipart = isMultipart(streams);
768-
769-
if (streams == null || isMultipart) {
763+
} else if (streams == null || isMultipart) {
770764
// send server list and request list as query string params
771765
ModifiableSolrParams queryParams = calculateQueryParams(this.urlParamNames, wparams);
772766
queryParams.add(calculateQueryParams(solrRequest.getQueryParams(), wparams));
@@ -824,18 +818,14 @@ private Request fillContentStream(
824818
}
825819
if (streams != null) {
826820
for (ContentStream contentStream : streams) {
827-
// Move contentType initialization closer to where it's used
828821
String contentType = contentStream.getContentType();
829822
if (contentType == null) {
830823
contentType = "multipart/form-data"; // default
831824
}
832-
833-
// Move name initialization closer to where it's used
834825
String name = contentStream.getName();
835826
if (name == null) {
836827
name = "";
837828
}
838-
839829
HttpFields.Mutable fields = HttpFields.build(1);
840830
fields.add(HttpHeader.CONTENT_TYPE, contentType);
841831
content.addPart(
@@ -850,7 +840,6 @@ private Request fillContentStream(
850840
}
851841
} else {
852842
// application/x-www-form-urlencoded
853-
// Move queryString initialization into the else block where it's used
854843
String queryString = wparams.toQueryString();
855844
// remove the leading "?" if there is any
856845
queryString = queryString.startsWith("?") ? queryString.substring(1) : queryString;

0 commit comments

Comments
 (0)