Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] 解决json配置文件在热更新时,因系统触发两次文件写入事件,第一次读取到的配置内容为空,导致json解析失败报错的问题 #3431

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[fix] 解决json配置文件在热更新时,因系统触发两次文件写入事件,第一次读取到的配置内容为空,导致json解析失败报错的问题
  • Loading branch information
hesu committed Sep 28, 2024
commit 62fad1d9f1a5b6c3e0e197cf2a9ed9d8879e83df
3 changes: 3 additions & 0 deletions encoding/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func (codec) Marshal(v interface{}) ([]byte, error) {
}

func (codec) Unmarshal(data []byte, v interface{}) error {
if len(data) == 0 {
return nil
}
switch m := v.(type) {
case json.Unmarshaler:
return m.UnmarshalJSON(data)
Expand Down