groovy

Missing 2 else's in InvokerHelper.setAttribute()

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor 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 :
    0

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);
    }

Activity

Hide
blackdrag blackdrag added a comment -

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.

Show
blackdrag blackdrag added a comment - 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.
Hide
blackdrag blackdrag added a comment -

fixed

Show
blackdrag blackdrag added a comment - fixed

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: