palantir / conjure-java

Conjure generator for Java clients and servers
Apache License 2.0
27 stars 43 forks source link

`Double` Alias types with log safety equality fix #2295

Closed felixdesouza closed 5 months ago

felixdesouza commented 5 months ago

Before this PR

After #2291 merged, some tests started failing in a specific case of an aliased Double that had safety annotations on.

The equalTo method was now generating something like this:

-Double.doubleToLongBits(this.value) == Double.doubleToLongBits(((Float) other).value))
+this.value == other.value

https://github.com/palantir/conjure-java/blob/7891d80363baa9843cc75b39b8a04d1430be1a2e/conjure-java-core/src/main/java/com/palantir/conjure/java/types/MethodSpecs.java#L93-L97

The type we pass in is ConjureAnnotations.withSafety(<underlying type>) and if you have any safety annotations, you end up with a TypeName.Double with annotations on top which are not equal to TypeName.Double, hence why we're hitting the second block.

This was the confusing part as AliasDoubleExample was actually generating the correct output.

After this PR

==COMMIT_MSG== Ensure that Aliased Double types with specified log safety have a correct equalTo. ==COMMIT_MSG==

Possible downsides?

changelog-app[bot] commented 5 months ago

Generate changelog in changelog-dir>`changelog/@unreleased`</changelog-dir

What do the change types mean? - `feature`: A new feature of the service. - `improvement`: An incremental improvement in the functionality or operation of the service. - `fix`: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way. - `break`: Has the potential to break consumers of this service's API, inclusive of both Palantir services and external consumers of the service's API (e.g. customer-written software or integrations). - `deprecation`: Advertises the intention to remove service functionality without any change to the operation of the service itself. - `manualTask`: Requires the possibility of manual intervention (running a script, eyeballing configuration, performing database surgery, ...) at the time of upgrade for it to succeed. - `migration`: A fully automatic upgrade migration task with no engineer input required. _Note: only one type should be chosen._
How are new versions calculated? - ❗The `break` and `manual task` changelog types will result in a major release! - 🐛 The `fix` changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease. - ✨ All others will result in a minor version release.

Type

- [ ] Feature - [ ] Improvement - [x] Fix - [ ] Break - [ ] Deprecation - [ ] Manual task - [ ] Migration

Description

Ensure that Aliased `Double` types with specified log safety have a correct `equalTo`. **Check the box to generate changelog(s)** - [x] Generate changelog entry
svc-autorelease commented 5 months ago

Released 8.21.0