smithy-lang/smithy

ShapeId static methods not consistent in their use of caching

Closed this issue · 1 comments

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?

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