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

Support content type application/x-ndjson in DeprecationRestHandler #36025

Merged
merged 2 commits into from
Nov 29, 2018

Conversation

jakelandis
Copy link
Contributor

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 #35958

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
@jakelandis jakelandis added :Core/Infra/REST API REST infrastructure and utilities v7.0.0 v6.6.0 labels Nov 29, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Member

@jasontedor jasontedor left a 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.

@jakelandis
Copy link
Contributor Author

@jasontedor - thanks! I split the tests into two as described and also moved the mock initialization to @Before to ensure clean mocks for each test. Will merge on green.

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks.

@jakelandis jakelandis merged commit f8636e5 into elastic:master Nov 29, 2018
jakelandis added a commit that referenced this pull request Nov 29, 2018
…#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants