JC created CLOUDSTACK-9856: ------------------------------ Summary: Possible code smell that returns always true in if condition Key: CLOUDSTACK-9856 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9856 Project: CloudStack Issue Type: Bug Security Level: Public (Anyone can view this level - this is the default.) Reporter: JC Priority: Trivial
Hi In recent Github mirror, I've found following code smell. Path: framework/db/src/com/cloud/utils/db/EcInfo.java {code} 51 Class<?> rawClazz = (Class<?>)rawType; 52 try { 53 if (!Modifier.isAbstract(rawClazz.getModifiers()) && !rawClazz.isInterface() && rawClazz.getConstructors().length != 0 && 54 rawClazz.getConstructor() != null) { 55 rawClass = rawClazz; 56 } else if (Set.class == rawClazz) { 57 rawClass = HashSet.class; 58 } else if (List.class == rawClazz) { 59 rawClass = ArrayList.class; 60 } else if (Collection.class == Collection.class) { 61 rawClass = ArrayList.class; 62 } else { 63 assert (false) : " We don't know how to create this calss " + rawType.toStri ng() + " for " + attr.field.getName(); 64 } 65 } catch (NoSuchMethodException e) { 66 throw new CloudRuntimeException("Write your own support for " + rawClazz + " def ined by " + attr.field.getName()); {code} Since I don't have domain knowledge about this project, I have no idea, rawClazz can have other types rather Set or List. If rawClazz can have other types, it will always be ArrayList.class as default (Line 60 and 61). So, the else block is dead code. It seems this is intended but wanted to report just in case. Thanks! -- This message was sent by Atlassian JIRA (v6.3.15#6346)