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

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

Open
waooog opened this issue Apr 16, 2017 · 0 comments

Comments

@waooog
Copy link

waooog commented Apr 16, 2017

我们的自动化缺陷检测工具扫描 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();

bwzheng2010 added a commit that referenced this issue Nov 8, 2017
fix bug: 使用 “==” 比较两个相同的表达式 (EqualToSameExpression) #90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant