smithy-lang / smithy

Smithy is a protocol-agnostic interface definition language and set of tools for generating clients, servers, and documentation for any programming language.
https://smithy.io
Apache License 2.0
1.7k stars 201 forks source link

ShapeId static methods not consistent in their use of caching #2242

Closed kubukoz closed 2 months ago

kubukoz commented 2 months ago

This isn't an issue per se (at least I don't think it is), but it has bitten us due to us accidentally relying on reference equality (== instead of equals):

ShapeId.from("foo.bar#Baz") == ShapeId.from("foo.bar#Baz") //true
ShapeId.from("foo.bar#Baz") == ShapeId.fromParts("foo.bar", "Baz") //false

The first line returns true because the cache kicks in and the instance is reused. However, in the latter, it appears that fromParts doesn't utilize the cache, and the comparison returns false.

Should this be fixed somehow, by having fromParts and friends also go through the cache?

mtdowling commented 2 months ago

No, sorry. We don’t guarantee reference equality for ShapeIds.