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

get*ExpectedValue methods' return type change not backwards compatible #2002

Closed
anuraaga opened this issue Apr 17, 2020 · 5 comments
Closed
Labels
bug A general bug
Milestone

Comments

@anuraaga
Copy link
Contributor

anuraaga commented Apr 17, 2020

I noticed 3da05bb has a backwards incompatible change of the return type from Long getMaximumExpectedValue() to Double getMaximumExpectedValue(). Since micrometer uses semantic versioning, as documented at https://micrometer.io/docs/support, I guess this wasn't intended?

Because of the change, all Armeria users are locked into 1.3.x, and if a library targeted 1.4.x and used a new API, it would be impossible to use this library with Armeria without asking it to downgrade, possibly losing some monitoring features. For reference, this change downgraded Armeria's dependency from 1.4.x to 1.3.x, requiring code change since they are not API or ABI compatible.

line/armeria@890631e#diff-c966b7c3ea79ab16c67724170ff57f47R115

I understand that 1.4.x is not LTS, but I guess that doesn't preclude it from actually being used, it's more about whether it gets patch updates or not. But with this API break, more and more users will be unable to use it due to the API mismatch.

Unfortunately 1.4.x is released, but do you think we can add a method to both 1.3.x and 1.4.x, getMaximumExpectedValueAsDouble to provide libraries a way to work with both versions?

@shakuzen
Copy link
Member

Just something that came to mind, here's a hack I think should work with 1.3.x and 1.4.x:

Long someLong = (distributionStatisticConfig.getMaximumExpectedValue() == null) ? null : ((Number) distributionStatisticConfig.getMaximumExpectedValue()).longValue();
Double someDouble = distributionStatisticConfig.getMinimumExpectedValue() == null ? null : ((Number) distributionStatisticConfig.getMinimumExpectedValue()).doubleValue();

@anuraaga
Copy link
Contributor Author

I would have to try to make sure, but pretty sure it doesn't work since Long vs Double are not ABI compatible so the method call itself will crash with NoSuchMethodError

'java.lang.Long io.micrometer.core.instrument.distribution.DistributionStatisticConfig.getMaximumExpectedValue()'
java.lang.NoSuchMethodError: 'java.lang.Long io.micrometer.core.instrument.distribution.DistributionStatisticConfig.getMaximumExpectedValue()'
	at com.linecorp.armeria.common.metric.MoreMeters.newTimer(MoreMeters.java:115)

@shakuzen
Copy link
Member

Alright. Although we'll have to introduce some stuff to bridge compatibility (thanks for the pull requests, by the way), I'd like to get back to a state of a single method (ideally named without asX) per single purpose in as few releases while allowing compatibility between at least adjacent minor versions (conservatively, LTS minor versions). I'm proposing the following plan (using the getMin method as an example):

1.1.x 1.3.8+ 1.4.2+ ^ 1.5.x Next LTS Next next LTS
  • Long getMin
  • Long getMin
  • Double getMinAsD
  • Double getMin
  • Double getMinAsD
  • Double getMin
  • Double getMinAsD
  • Double getMin
  • Double getMinAsD
  • Double getMin
  • ^ non-LTS minor
    deprecated

    What do you think? Does this seem like a reasonable plan to get things back to a good state while allowing libraries like Armeria to be compatible with a range of Micrometer versions?

    @anuraaga
    Copy link
    Contributor Author

    anuraaga commented Apr 20, 2020

    Agree getting to one method is important and the plan looks fine to me. But we should clarify, I guess next-next LTS here will be 2.x since it removes the API and needs to use semantic versioning?

    shakuzen added a commit that referenced this issue Apr 23, 2020
    …2004)
    
    This allow libraries to use these methods regardless of whether 1.3.x or 1.4.x is on the classpath. Deprecates the existing methods so users know to switch to the new ones to remain compatible.
    
    See #2002
    
    Co-authored-by: Tommy Ludwig <8924140+shakuzen@users.noreply.github.com>
    @shakuzen
    Copy link
    Member

    This should be resolved now thanks to @anuraaga's pull requests. Please check snapshots and let me know if not. We'll be releasing patch versions soon.

    @shakuzen shakuzen changed the title 1.3.x and 1.4.x not compatible get*ExpectedValue methods return type change not backwards compatible Apr 23, 2020
    @shakuzen shakuzen changed the title get*ExpectedValue methods return type change not backwards compatible get*ExpectedValue methods' return type change not backwards compatible Apr 23, 2020
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    bug A general bug
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants