Skip to content

[Bug] Incorrect reflection parameter in RaftEngine.getState method #2867

@haohao0103

Description

@haohao0103

Bug Type (问题类型)

other exception / error (其他异常报错)

Before submit

  • 我已经确认现有的 IssuesFAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)

Environment (环境信息)

  • Server Version: 1.5.0 (master)

Expected & Actual behavior (期望与实际表现)

There is a reflection call error in the getState method of the PD RaftEngine.java file. This method attempts to retrieve the state field value of a Replicator object through reflection, but incorrectly uses this.raftNode as the parameter instead of the passed Replicator r parameter.

private Replicator.State getState(Replicator r) {
    var clz = r.getClass();
    try {
        var f = clz.getDeclaredField("state");
        f.setAccessible(true);
        var state = (Replicator.State) f.get(this.raftNode); // Error: should use r instead of this.raftNode
        f.setAccessible(false);
        return state;
    } catch (NoSuchFieldException | IllegalAccessException e) {
        log.info("getReplicatorGroup: error {}", e.getMessage());
        return null;
    }
}

Vertex/Edge example (问题点 / 边数据举例)

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingraft

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions