Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1164

Incorrect "contains multiple setters for the same property" error output for bridge methods

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.7
    • Fix Version/s: 1.1.8
    • Component/s: logback-core
    • Labels:

      Description

      In logback 1.1.7, BeanDescriptionFactory was introduced in this commit.

      BeanDescriptionFactory incorrectly prints the following warnings for classes containing bridge methods:

      Warning: Class '%s' contains multiple setters for the same property '%s'.
      Warning: Class '%s' contains multiple adders for the same property '%s'.
      

      BeanDescriptionFactory should ignore bridge methods.

      This could be fixed easily by adding:

      if (method.isBridge()) {
          continue;
      }
      

      in the for loop, before the first if condition.

      This can be reproduced by using a class with a bridge method in logback's configuration. For example:

      public class ConfigFoo<T> {
          private T bar;
          public void setBar(T bar) {
              this.bar = bar;
          }
      }
      
      public class IntegerConfigFoo extends ConfigFoo<T> {
          public void setBar(Integer bar) {
              super.setBar(bar);
              // do something else
          }
      }
      

      In this case IntegerConfigFoo will have a setBar(Object) bridge method AND a setBar(Integer) method. Logback should ignore the setBar(Object) bridge method.

      This is causing issues for logstash-logback-encoder

        Attachments

          Activity

            People

            • Assignee:
              ceki Ceki Gülcü
              Reporter:
              philsttr Phil
            • Votes:
              7 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: