-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Support content type application/x-ndjson
in DeprecationRestHandler
#36025
Support content type application/x-ndjson
in DeprecationRestHandler
#36025
Conversation
org.elasticsearch.rest.RestController#hasContentType checks to see if the RestHandler supports the `application/x-ndjson` Content-Type. DeprecationRestHandler is a wrapper around the real RestHandler, and prior to this change would always return `false` due to the interface's default supportsContentStream(). This prevents API's that use multi-line JSON from properly being deprecated resulting in an HTTP 406 error. This change ensures that the DeprecationRestHandler honors the supportsContentStream() of the wrapped RestHandler. Part of elastic#35958
Pinging @elastic/es-core-infra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. Let's not make this mistake again. We should have a wrapper rest handler that wraps a rest handler and delegates all methods to the wrapped rest handler. Then deprecation rest handler is a special wrapper rest handler.
The production code LGTM to fix the immediate issue though.
I would rather two separate tests though, one for the case when the underlying handler returns false for supportsContentStream, and one for the case when the underlying handler returns true.
@jasontedor - thanks! I split the tests into two as described and also moved the mock initialization to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks.
…#36025) org.elasticsearch.rest.RestController#hasContentType checks to see if the RestHandler supports the `application/x-ndjson` Content-Type. DeprecationRestHandler is a wrapper around the real RestHandler, and prior to this change would always return `false` due to the interface's default supportsContentStream(). This prevents API's that use multi-line JSON from properly being deprecated resulting in an HTTP 406 error. This change ensures that the DeprecationRestHandler honors the supportsContentStream() of the wrapped RestHandler. Relates to #35958
org.elasticsearch.rest.RestController#hasContentType checks to see if the
RestHandler supports the
application/x-ndjson
Content-Type. DeprecationRestHandleris a wrapper around the real RestHandler, and prior to this change
would always return
false
due to the interface's default supportsContentStream().This prevents API's that use multi-line JSON from properly being deprecated
resulting in an HTTP 406 error.
This change ensures that the DeprecationRestHandler honors the
supportsContentStream() of the wrapped RestHandler.
Part of #35958