alibaba / jstorm

Enterprise Stream Process Engine
http://jstorm.io
Apache License 2.0
3.91k stars 1.81k forks source link

jstorm-core内冗余的实例化对象 (RedundantInstantiation) #489

Open waooog opened 7 years ago

waooog commented 7 years ago

我们的自动化缺陷检测工具扫描 jstorm-core的源代码,发现了一处潜在的code smell/bug:

路径:jstorm-core/src/main/java/com/alibaba/jstorm/container/CgroupCenter.java

代码片段:

public List<Hierarchy> getHierarchies() {
...
Hierarchy h = hierarchies.get(type);
h = new Hierarchy(name, CgroupUtils.analyse(type), dir);
...
}

上述代码片段中,Hierarchy的对象h 被连续两次初始化,建议修改为:

Hierarchy h = new Hierarchy(name, CgroupUtils.analyse(type), dir);

fengjian428 commented 7 years ago

你提一个PR好了

waooog commented 7 years ago

好的,已经建了一个PR了, 谢谢.