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

fix: check changes in return types #397

Merged
merged 3 commits into from
May 3, 2024
Merged

Conversation

Billlynch
Copy link
Contributor

I noticed that the maven plugin does not break on METHOD_RETURN_TYPE_GENERICS_CHANGED.

This looked to be because method is not given a JApiCompatibilityChange, but instead the return type of the method is given a JApiCompatibilityChange.

addCompatibilityChange(method.getReturnType(), JApiCompatibilityChangeType.METHOD_RETURN_TYPE_GENERICS_CHANGED);

So added a check for the compatibility changes in the return types of methods.

@Billlynch
Copy link
Contributor Author

Billlynch commented Apr 26, 2024

Also the JApiCompatibilityChange could be added to the method not the return type, as the return type has changed. I did not go for this approach off the bat because there are multiple tests that specify this behaviour.

This could be done by checking here if the generic return type is different and putting the JApiChangeStatus to MODIFIED. Adjusting accordingly in the check method. I think this is following the section 13.4.15 of the SE7 java spec a little more accurately.

Copy link
Owner

@siom79 siom79 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR and your work on it. It looks good, I only have one question.


for (JApiCompatibilityChange change : jApiMethod.getReturnType().getCompatibilityChanges()) {
if (!change.isBinaryCompatible() || !change.isSourceCompatible()) {
if (!change.isBinaryCompatible() && options.isErrorOnBinaryIncompatibility()) {
Copy link
Owner

Choose a reason for hiding this comment

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

Shouldn't this be the same as in the line 218? I mean the exclusion of the method is not checked. And if it is the same as in line 218 then this block could be refactored to a method called with the two sets of JApiCompatibilityChange.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, good suggestion. Will change and refactor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@siom79 siom79 merged commit 317f263 into siom79:master May 3, 2024
6 checks passed
@siom79
Copy link
Owner

siom79 commented May 3, 2024

Thanks again for the PR and your work.

@siom79
Copy link
Owner

siom79 commented May 3, 2024

0.21.2 is on its way to Maven central.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants