Open sagebind opened 5 years ago
Interesting point. If we do change the default behavior, will that break anyone?
It is certainly possible that someone is relying on the current behavior, though this is bad enough that I would call it a significant bug that should be fixed.
The type adapter included by default for
java.net.URI
does not preserve the identity of all URI values. In other words:The problem is that the implementation here uses
URI#toASCIIString
, which does not preserve the original URI components but instead normalizes them like this:This is very bad, because it is changing the meaning of the URI on serialization. This issue has caused numerous bugs at our business dealing with international filenames being uploaded to our SAAS products and then being changed after being passed between multiple microservices.
Here is an alternate implementation that we have started to use in our code:
Really the only difference is using
toString()
instead oftoASCIIString()
, which URL-encodes the result without changing the character byte representations.