isaric commented on code in PR #4946:
URL: https://github.com/apache/solr/pull/4946#discussion_r4709842882
##########
solr/core/src/java/org/apache/solr/jersey/MediaTypeOverridingFilter.java:
##########
@@ -50,8 +52,15 @@ public void filter(
ContainerRequestContext requestContext, ContainerResponseContext
responseContext)
throws IOException {
- // Solr has historically ignored 'wt' for client or server error
responses, so maintain that
- // behavior here for compatibility.
+ if (requestContext.getUriInfo().getQueryParameters().containsKey(WT)) {
+ DeprecationLog.log(
Review Comment:
SolrJ still sends `wt` on v2 requests (see
HttpSolrClient.initializeSolrParams), so this fires on every node the first
time a SolrJ client hits a v2 endpoint, including Solr's own node-to-node
calls. Either stop SolrJ sending `wt` for v2, or only warn when `wt` is present
and no `Accept` header is.
##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java:
##########
@@ -163,6 +165,39 @@ protected ModifiableSolrParams initializeSolrParams(
return params;
}
+ // ResponseParser#getContentTypes() is contractually stable per parser (same
Set instance every
+ // call), so the 'Accept' header derived from it is cacheable; this avoids
rebuilding the same
+ // joined string on every request. Bounded in size by the number of distinct
ResponseParser
+ // content-type sets in the JVM, which is small and fixed.
+ private static final Map<Collection<String>, String> ACCEPT_HEADER_CACHE =
+ new ConcurrentHashMap<>();
+
+ /**
+ * The 'Accept' header value that requests the response format {@code
parserToUse} can read, or
+ * {@code null} if the parser doesn't care (in which case no 'Accept' header
is added, and the
+ * server picks its own default -- currently JSON for v2 APIs).
+ */
+ protected static String acceptHeaderFor(ResponseParser parserToUse) {
Review Comment:
Since the Accept header now carries the format, `initializeSolrParams` a few
lines up could skip setting `wt` for v2 requests (`isV2ApiRequest` exists and
is unused). That makes the changelog's 'SolrJ users are unaffected' literally
true and keeps the new server-side warning from firing on SolrJ's own traffic.
##########
solr/core/src/test/org/apache/solr/pkg/TestPackages.java:
##########
@@ -683,14 +683,14 @@ public void testAPI() throws Exception {
// So far we have been verifying the details with ZK directly
// use the package read API to verify with each node that it has the
correct data
for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {
- String path = jetty.getBaseURLV2().toString() +
"/cluster/package?wt=javabin";
+ String path = jetty.getBaseURLV2().toString() + "/cluster/package";
TestDistribFileStore.assertResponseValues(
10,
new Callable<NavigableObject>() {
@Override
public NavigableObject call() throws Exception {
HttpClient solrClient = jetty.getSolrClient().getHttpClient();
- byte[] bytes = solrClient.GET(path).getContent();
+ byte[] bytes = solrClient.GET(path + "?wt=javabin").getContent();
Review Comment:
Obsolete after rebase: main already drives this through `new
V2Request.Builder("/cluster/packages")`, so this hunk (and the raw `wt=javabin`
GET) goes away.
--
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]