Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

[bug] 使用 “==” 比较两个相同的表达式 (EqualToSameExpression) #90

@waooog

Description

@waooog

我们的自动化缺陷检测工具扫描 mdrill的源代码,发现了一个严重的bug:

路径:adhoc-internal/src/main/java/org/jfree/util/PaintUtilities.java

代码片段:

public static boolean equal(final Paint p1, final Paint p2) {
...
 if (p1 instanceof GradientPaint && p2 instanceof GradientPaint) {
            final GradientPaint gp1 = (GradientPaint) p1;
            final GradientPaint gp2 = (GradientPaint) p2;
            result = gp1.getColor1().equals(gp2.getColor1()) 
                && gp1.getColor2().equals(gp2.getColor2())
                && gp1.getPoint1().equals(gp2.getPoint1())    
                && gp1.getPoint2().equals(gp2.getPoint2())
                && gp1.isCyclic() == gp2.isCyclic()
                && gp1.getTransparency() == gp1.getTransparency(); 
        }
...
}

上述代码片段中的if语句的 gp1.getTransparency() == gp1.getTransparency(); 恒为true, 建议修改为:

gp1.getTransparency() == gp2.getTransparency();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions