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

Plugin#onModule methods are deprecated and final #20564

Closed
javanna opened this issue Sep 19, 2016 · 7 comments
Closed

Plugin#onModule methods are deprecated and final #20564

javanna opened this issue Sep 19, 2016 · 7 comments
Assignees
Labels
:Core/Infra/Plugins Plugin API and infrastructure

Comments

@javanna
Copy link
Member

javanna commented Sep 19, 2016

Plugin#onModule methods are deprecated as they have been replaced by specific plugin classes that need to be extended depending on the type of plugin and the needed functionalities. In the past those onModule methods were called via reflection and received some specific guice module as an argument and allowed to do many things with it, probably too many.

Now that there is a replacement, it makes sense to deprecate these onModule methods, but I don't get why we would leave them behind, make them final, hence unusable by plugins, and deprecate them at the same time. Either they should be usable but deprecated, or they should be gone. Making them final is the same as removing them I think? What we have now just makse people that used them angry I think :) Or maybe there are reasons why this was done that I am missing, not sure.

@javanna javanna added >bug discuss :Core/Infra/Plugins Plugin API and infrastructure labels Sep 19, 2016
@nik9000
Copy link
Member

nik9000 commented Sep 19, 2016

Now that there is a replacement, it makes sense to deprecate these onModule methods, but I don't get why we would leave them behind, make them final, hence unusable by plugins, and deprecate them at the same time.

I like the way we have it because you get a compiler error in your plugin as soon as you try to compile it against 5.0. I imagine you'll get dozens, but at least this one points you right to trying to override a final method and when you look at the method it tells you what to do instead. I think technically this is the wrong way to use deprecated because, like you say, if you mark something as deprecated it should continue to work for a version or so. But we don't have that kind of stability for plugins. In this case deprecated just gives us a convenient space to stick a string. I think it'd be more correct to remove @Deprecated and keep the final method with the warnings in the javadoc. But I think what we have is fine.

I haven't read the specification for the @Deprecation annotation in a while so I could be totally wrong.

@s1monw
Copy link
Contributor

s1monw commented Sep 19, 2016

@javanna I think there is one little detail that isn't obvious. Today if you implement a onModule(SomeModule foo) you don't actually override anything. The super class doesn't implement those methods. Guice applies some magic to invoke these methods, if you have a typo in there nothing happens. Now we defined them as final to ensure users that implement them get a compilation error. I wonder if we should add a comment to this class explaining that?

@nik9000
Copy link
Member

nik9000 commented Sep 19, 2016

Guice applies some magic to invoke these methods

That magic is all home grown.

I wonder if we should add a comment to this class explaining that?

I think @deprecated implement {@link ActionPlugin} instead is pretty descriptive. I'd be happy to stick some more words in the class level Javadoc to make it more clear though.

@javanna
Copy link
Member Author

javanna commented Sep 19, 2016

yea the problems caused by using reflection are clear to me. If this was all done on purpose I am ok with it. It's just that finding the methods deprecated seems like a joke, cause they are effectively gone :) We could have been nicer and only deprecate those methods in 5.0 and remove them in 6.0, but I know we don't do this for plugins so anything would have upset plugin developers anyways and using deprecated doesn't make a lot of difference after all.

@s1monw
Copy link
Contributor

s1monw commented Sep 19, 2016

That magic is all home grown.

dude, I know :) we fork it so I am not blaming anybody upstream

I think @deprecated implement {@link ActionPlugin} instead is pretty descriptive. I'd be happy to stick some more words in the class level Javadoc to make it more clear though.

++

yet I mean we should put some in-line comments why we make this final at all

@javanna
Copy link
Member Author

javanna commented Sep 19, 2016

yet I mean we should put some in-line comments why we make this final at all

++ if somebody doesn't know (like me today) they may think it's a bug or a silly mistake

@javanna javanna removed the >bug label Sep 19, 2016
@nik9000 nik9000 self-assigned this Sep 19, 2016
@nik9000
Copy link
Member

nik9000 commented Sep 19, 2016

Right. I've assigned this to myself and stuck this at the head of my fancy to-do queue (browser tabs).

@nik9000 nik9000 removed the discuss label Sep 19, 2016
nik9000 added a commit to nik9000/elasticsearch that referenced this issue Sep 19, 2016
Adds some javadoc with more explanation on how to extend Plugin and
why we have all these `@Deprecated public final` `onModule` methods.

Closes elastic#20564
nik9000 added a commit that referenced this issue Sep 20, 2016
Adds some javadoc with more explanation on how to extend Plugin and
why we have all these `@Deprecated public final` `onModule` methods.

Closes #20564
nik9000 added a commit that referenced this issue Sep 20, 2016
Adds some javadoc with more explanation on how to extend Plugin and
why we have all these `@Deprecated public final` `onModule` methods.

Closes #20564
nik9000 added a commit that referenced this issue Sep 20, 2016
Adds some javadoc with more explanation on how to extend Plugin and
why we have all these `@Deprecated public final` `onModule` methods.

Closes #20564
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Plugins Plugin API and infrastructure
Projects
None yet
Development

No branches or pull requests

3 participants