Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-17589 First use of PUT/POST request with HttpJdkSolrClient generates error log entry on solr server due to initial HEAD request #2926

Merged
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ Other Changes

* SOLR-16503: Most remaining usages of Apache HttpClient in Solr switched to Jetty HttpClient (HTTP 2). (Sanjay Dutt, David Smiley)

* SOLR-17589: Prevent error log entry on solr server due to initial HEAD request from HttpJdkSolrClient. (Paul Blanchaert via James Dyer)

================== 9.8.0 ==================
New Features
---------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ private synchronized boolean maybeTryHeadRequestSync(String url) {
}
HttpRequest.Builder headReqB =
HttpRequest.newBuilder(uriNoQueryParams)
.method("HEAD", HttpRequest.BodyPublishers.noBody());
.method("HEAD", HttpRequest.BodyPublishers.noBody())
.header("Content-Type", ClientUtils.TEXT_JSON);
decorateRequest(headReqB, new QueryRequest());
try {
httpClient.send(headReqB.build(), HttpResponse.BodyHandlers.discarding());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,21 @@ public void testPing() throws Exception {
}
}

@Test
public void testMaybeTryHeadRequestHasContentType() throws Exception {
DebugServlet.clear();
String url = getBaseUrl() + DEBUG_SERVLET_PATH;
try (HttpJdkSolrClient client = builder(url).build()) {
assertTrue(client.maybeTryHeadRequest(url));

// if https, the client won't attempt a HEAD request
if (client.headRequested) {
assertEquals("head", DebugServlet.lastMethod);
assertTrue(DebugServlet.headers.containsKey("content-type"));
}
}
}

/**
* This is not required for any test, but there appears to be a bug in the JDK client where it
* does not release all threads if the client has not performed any queries, even after a forced
Expand Down
Loading