Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.5.4
-
Fix Version/s: 1.5.5, 1.6-beta-1
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
It seems we are missing some else's in this method
public static void setAttribute(Object object, String attribute, Object newValue) { if (object instanceof Class) { metaRegistry.getMetaClass((Class) object).setAttribute(object, attribute, newValue); } if (object instanceof GroovyObject) { ((GroovyObject) object).getMetaClass().setAttribute(object, attribute, newValue); } metaRegistry.getMetaClass(object.getClass()).setAttribute(object, attribute, newValue); }
hmm... in case of a missing attribute this is no problem, if object is a Class and the class named by this has a static field, then the first call succeeds, the next if is false and finally the cold would try to set the value on the class Class.... that looks like an error then. If object is a GroovyObject, then the wrong MetaClass might be used to set the attribute.. again an error then. if object is no instance of GroovyObject, then the code is correct... so yes, the 2 "else" are missing.