stillalex commented on code in PR #1447:
URL: https://github.com/apache/solr/pull/1447#discussion_r1134622378
##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -909,6 +889,44 @@ private NamedList<Object> processErrorsAndResponse(
}
}
+ /**
+ * Validates that the content type in the response can be processed by the
Response Parser. Throws
+ * a {@code RemoteSolrException} if not.
+ */
+ private void checkContentType(
+ ResponseParser processor, InputStream is, String mimeType, String
encoding, int httpStatus) {
+ if (processor == this.parser && defaultMimeTypes.contains(mimeType)) {
+ // Shortcut the default scenario
+ return;
+ }
+ final Collection<String> processorSupportedContentTypes =
processor.getContentTypes();
+ if (processorSupportedContentTypes != null &&
!processorSupportedContentTypes.isEmpty()) {
+ final Collection<String> processorMimeTypes =
Review Comment:
I know this code was moved 'as is' but will leave the comment here in case
there is interest in the proposal: what about using a lookup on the stream that
can shortcut instead of building the entire set of mimeTypes. something along
the lines of
```
boolean contains = processorSupportedContentTypes.stream()
.map(ct -> ContentType.parse(ct).getMimeType().trim())
.anyMatch(supported -> mimeType.equalsIgnoreCase(supported));
```
this would stop as soon as the mimeType is found. granted there are probably
not many entries in that set anyway so maybe not worth the trouble
--
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]