Skip to content

Update BaseRestHandler to implement default routes #694

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

Closed
saratvemulapalli opened this issue May 12, 2021 · 4 comments
Closed

Update BaseRestHandler to implement default routes #694

saratvemulapalli opened this issue May 12, 2021 · 4 comments
Labels
backwards-compatibility enhancement Enhancement or improvement to existing feature or request

Comments

@saratvemulapalli
Copy link
Member

Describe the bug
Update BaseRestHandler to implement default routes() instead of an abstract class.
This will help developers not to implement empty methods even though they don't need it.
They can always override the method if they'd like.

public abstract List<Route> routes();

Expected behavior
Return an empty list so that classes which extend do not have implement empty methods even if they don't have to.

Plugins
OpenSearch Anomaly-Detection

Host/Environment (please complete the following information):

  • OS: Linux x64
@dblock
Copy link
Member

dblock commented May 13, 2021

In this case routes is not required because all the routes have replacedRoutes.

@VijayanB
Copy link
Member

VijayanB commented May 13, 2021

routes() method is from interface RestHandler, which already has default implementation here. if we remove this method from BaseRestHandler, we don't have to override at subclass extending BaseRestHandler.

@Bukhtawar
Copy link
Contributor

Can we have a way to enforce one of routes or replacedRoute as I don't think a RestHandler should exist without a route. This proposal can allow the plugin implementation to get away without providing any of them which breaks the contract

@vrozov
Copy link
Contributor

vrozov commented Jul 6, 2021

Such a contract can't be enforced by Java. Any subclass that implements RestHandler can overwrite both routes() and replacedRoutes() and return empty list for both. Additionally, I don't think that enforcing that one of the methods returns a non-empty list is desirable. Some handlers may provide routes only under certain conditions/settings.

@saratvemulapalli saratvemulapalli removed their assignment Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards-compatibility enhancement Enhancement or improvement to existing feature or request
Projects
None yet
Development

No branches or pull requests

5 participants