b84330808 opened a new pull request, #16571:
URL: https://github.com/apache/dubbo/pull/16571
## What is the purpose of the change?
`FileCacheStore.refreshCache()` writes the local cache file (`.metadata`,
`.mapping`) with an `OutputStreamWriter` set to UTF-8, but `loadCache()` reads
it back with `FileReader`, which uses the platform charset. On JDK 8–17 with a
non-UTF-8 default, e.g. GBK on Chinese Windows, any non-ASCII text in the
cached `MetadataInfo` (such as a service parameter value) comes back garbled
after a restart.
`loadCache()` also splits each line on every `=`, so a value that contains
`=` (base64 padding, a parameter like `a=b`) is cut at the first one.
This reads the file as UTF-8 and splits only on the first `=`.
The new `FileCacheStoreTest#testLoadCacheReadsBackWhatRefreshCacheWrote`
writes two entries with `refreshCache()` and expects `loadCache()` to return
them unchanged. On `3.3` it fails:
```
expected: <{newKey2=a=b=c,
newKey1={"params":{"desc":"订单服务","token":"YWJjZA=="}}}>
but was: <{newKey2=a, newKey1={"params":{"desc":"订单服务","token":"YWJjZA}>
```
and with JDK 17 and `-Dargline=-Dfile.encoding=GBK` the value is also
garbled (`"desc":"璁㈠崟鏈嶅姟"`). It passes with the change.
## Checklist
- [ ] Make sure there is a
[GitHub_issue](https://github.com/apache/dubbo/issues) field for the change.
- [x] Write a pull request description that is detailed enough to understand
what the pull request does, how, and why.
- [x] Write necessary unit-test to verify your logic correction. If the new
feature or significant change is committed, please remember to add sample in
[dubbo samples](https://github.com/apache/dubbo-samples) project.
- [ ] Make sure gitHub actions can pass. [Why the workflow is failing and
how to fix it?](../CONTRIBUTING.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]