Skip to content

SOLR-17743: V2 API: use correct content-type #3326

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dsmiley
Copy link
Contributor

@dsmiley dsmiley commented Apr 14, 2025

https://issues.apache.org/jira/browse/SOLR-17743

I welcome input on testing (if needed).

Copy link
Contributor Author

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing to potentially fix is I observe that a request to GET a raw file has wt=json but we're not actually writing with that after all.

@@ -133,7 +133,6 @@ public class {{classname}} {
{{#isBodyParam}}
{{#vendorExtensions.x-genericEntity}}
this.requestBody = requestBody;
addHeader("Content-type", "application/json");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't belong here. It's the ContentWriter that's responsible for the type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do like that better from an abstraction perspective, but I remember putting this line here only after noticing that relying on the ContentWriter was leaving the header unset in some cases. I wish I remembered the context there better.

But let's not worry about that now - if it crops up again I'll reinvestigate at that point...

@@ -205,26 +203,23 @@ public class {{classname}} {

@Override
@SuppressWarnings("unchecked")
public RequestWriter.ContentWriter getContentWriter(String expectedType) {
public RequestWriter.ContentWriter getContentWriter(String _expectedTypeIGNORE) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getContentWriter is passed an "expectedType" from the SolrClient.requestWriter which defaults to "javabin". But V2 should ignore that requestWriter as it's opinionated on how to write -- only supports JSON via Jackson or raw writing. Perhaps that field in SolrClient should be named defaultRequestWriter... although we're not choosing a different RequestWriter so.... 🤷

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[0] Maybe some version of this rationale should live as a comment in the code/template, so that we can notice when those preconditions/assumptions change?

e.g.

// v2 currently only supports reading JSON request-bodies, so we ignore the expected type suggestion provided by callers.

Copy link
Contributor

@gerlowskija gerlowskija left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - though I left a few comments you can address or ignore as you choose!

@@ -205,26 +203,23 @@ public class {{classname}} {

@Override
@SuppressWarnings("unchecked")
public RequestWriter.ContentWriter getContentWriter(String expectedType) {
public RequestWriter.ContentWriter getContentWriter(String _expectedTypeIGNORE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[0] Maybe some version of this rationale should live as a comment in the code/template, so that we can notice when those preconditions/assumptions change?

e.g.

// v2 currently only supports reading JSON request-bodies, so we ignore the expected type suggestion provided by callers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants