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

Deprecate groovy #611

Merged
merged 2 commits into from Mar 29, 2017
Merged

Deprecate groovy #611

merged 2 commits into from Mar 29, 2017

Conversation

aledsage
Copy link
Contributor

As discussed on the dev@brooklyn mailing list (subject "[PROPOSAL] Remove groovy dependency/support").

Deprecate methods that take explicit groovy types (e.g. groovy.lang.Closure, groovy.time.TimeDuration, etc).

Also updates some javadoc that mentioned Closure to say that its usage is deprecated.

In some places, it does a LOG.warn() about the deprecation when a groovy Closure etc is passed in - this is when we can't just deprecate the method, e.g. for use of TypeCoercion on when the method takes Object and does an ugly instanceof.

This does not touch:

  • The org.apache.brooklyn.rest.resources.ScriptResource (for groovy-script execution)
  • Internal usage of groovy (e.g. AbstractManagementContext.invokeEffectorMethodLocal() calling GroovyJavaMethods.invokeMethodOnMetaClass)

Deprecate methods that take explicit groovy types (e.g. groovy.lang.Closure,
groovy.time.TimeDuration, etc).

Also updates some javadoc that mentioned “Closure” to say that its
Usage is deprecated.
Copy link
Member

@tbouron tbouron left a comment

Choose a reason for hiding this comment

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

Successfully built once rebased on the latest master (Jenkins issues are fixed by other merged PRs)

Few minor comment but otherwise, LGTM

public static <I,T> ExplicitEffector<I,T> create(String name, Class<T> type, List<ParameterType<?>> parameters, String description, Closure body) {
LOG.warn("Use of groovy.lang.Closure is deprecated, in ExplicitEffector.create()");
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we suggest another class/method to use in the warning message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added this to javadoc on the class - I think that's good enough, as there's not a direct replacement (i.e. one would extend AbstractEffector yourself instead, as we don't need to workaround for GROOVY-5122 if you're not using groovy - I'm not sure why anyone would want to do that).

I agree in general that if deprecating a method/class, one should point at the alternative - but if deprecating a class, I don't think we need it on every method.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough

/**
* @deprecated since 0.11.0; explicit groovy utilities/support will be deleted.
*/
@Deprecated
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we add a warning message here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My rule-of-thumb... if one might get at the code via a yaml blueprint (so never seeing a deprecation warning in your IDE/compiler), then we should include a log.warn. But if we can assume that the user will get compiler warnings, then that is sufficient.

I believe that this will only get called directly in code, so one should see a compiler warning.

/**
* @deprecated since 0.11.0; explicit groovy utilities/support will be deleted.
*/
@Deprecated
Copy link
Member

Choose a reason for hiding this comment

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

Is this one really deprecated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the parameter is of type groovy.time.TimeDuration.

@aledsage
Copy link
Contributor Author

@tbouron I've responded to your comments - do you agree with those, or do you think I should make further changes before merging the PR?

@tbouron
Copy link
Member

tbouron commented Mar 29, 2017

@aledsage Yes, I think that covers everything so LGTM 👍

@aledsage
Copy link
Contributor Author

Thanks @tbouron - merging now.

@asfgit asfgit merged commit 1d056d8 into apache:master Mar 29, 2017
asfgit pushed a commit that referenced this pull request Mar 29, 2017
@aledsage aledsage deleted the deprecate-groovy branch April 10, 2017 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants