Uploaded image for project: 'Errai'
  1. Errai
  2. ERRAI-869

BindableProxyAgent.copyValues calls "is" methods even when no property exists

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 3.1.2.Final
    • Fix Version/s: None
    • Component/s: ErraiDataBinding
    • Labels:
      None

      Description

      Encounted a NPE on my end that took a long time to figure out what was happening. I have a rather large (30+ property) POJO that is marked @Bindable.

      I have a method "isFormUnit() that looks like it would be for a boolean property 'formUnit', but in fact, it isn't (there is no 'formUnit' property). When the copyValues() method is called on the BindableProxyAgent, the isFormUnit() was firing, which was causing an NPE (because I wasn't checking).

      I traced the code I believe to AbstractMetaClass.getBeanDescriptor:667

      final String property = ReflectionUtil.getPropertyFromAccessor(method.getName());
      
      if (method.getParameters().length == 0
        && (method.getName().startsWith("get") || method.getName().startsWith("is"))) {
        properties.add(property);
        getterProperties.put(property, method);
       

      I believe there should be another check to see that there is in fact a property 'property'.

      I realize this is pretty small, and a pretty obscure edge case. It only took me years to find it

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                csa Christian Sadilek
                Reporter:
                jblinick Josh B
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: