bugfix(raft): When the length of the data is 0, return directly without further decoding

Signed-off-by: chihe <chi.he@oppo.com>
(cherry picked from commit 5fdfe4eb5c31fbd028e1b00c2f228d26a683fd06)
This commit is contained in:
chihe 2023-12-07 17:35:42 -08:00 committed by AmazingChi
parent 9da5608432
commit d05405ef73

View File

@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@ -241,6 +241,9 @@ func (m *Message) Decode(r *util.BufferReader) error {
return err
}
if len(datas) == 0 {
return nil
}
ver := datas[0]
if ver == version1 {
m.Type = MsgType(datas[1])